2002-06-01 08:34:30 -04:00
/*
* ( c ) 1995 Microsoft Corporation . All rights reserved .
* Developed by ActiveWare Internet Corp . , http : //www.ActiveWare.com
*
* Other modifications Copyright ( c ) 1997 , 1998 by Gurusamy Sarathy
* < gsar @ umich . edu > and Jan Dubois < jan . dubois @ ibm . net >
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License , as specified in the README file
* of the Perl distribution .
*
*/
/*
modified for win32ole ( ruby ) by Masaki . Suketa < masaki . suketa @ nifty . ne . jp >
*/
2014-08-02 10:55:36 -04:00
# include "win32ole.h"
2007-03-02 07:35:02 -05:00
2008-10-12 20:03:11 -04:00
/*
2010-04-22 04:04:13 -04:00
* unfortunately IID_IMultiLanguage2 is not included in any libXXX . a
2008-10-12 20:03:11 -04:00
* in Cygwin ( mingw32 ) .
*/
# if defined(__CYGWIN__) || defined(__MINGW32__)
# undef IID_IMultiLanguage2
const IID IID_IMultiLanguage2 = { 0xDCCFC164 , 0x2B38 , 0x11d2 , { 0xB7 , 0xEC , 0x00 , 0xC0 , 0x4F , 0x8F , 0x5D , 0x9A } } ;
# endif
2015-02-04 06:30:37 -05:00
# define WIN32OLE_VERSION "1.8.4"
2002-06-01 08:34:30 -04:00
typedef HRESULT ( STDAPICALLTYPE FNCOCREATEINSTANCEEX )
( REFCLSID , IUnknown * , DWORD , COSERVERINFO * , DWORD , MULTI_QI * ) ;
typedef HWND ( WINAPI FNHTMLHELP ) ( HWND hwndCaller , LPCSTR pszFile ,
2004-02-15 01:53:15 -05:00
UINT uCommand , DWORD dwData ) ;
2007-01-20 07:12:36 -05:00
typedef BOOL ( FNENUMSYSEMCODEPAGES ) ( CODEPAGE_ENUMPROC , DWORD ) ;
2002-06-01 08:34:30 -04:00
VALUE cWIN32OLE ;
2014-08-13 08:46:23 -04:00
2013-01-25 05:17:59 -05:00
# if defined(RB_THREAD_SPECIFIC) && (defined(__CYGWIN__) || defined(__MINGW32__))
2013-01-17 21:23:37 -05:00
static RB_THREAD_SPECIFIC BOOL g_ole_initialized ;
# define g_ole_initialized_init() ((void)0)
# define g_ole_initialized_set(val) (g_ole_initialized = (val))
# else
static volatile DWORD g_ole_initialized_key = TLS_OUT_OF_INDEXES ;
# define g_ole_initialized (BOOL)TlsGetValue(g_ole_initialized_key)
# define g_ole_initialized_init() (g_ole_initialized_key = TlsAlloc())
# define g_ole_initialized_set(val) TlsSetValue(g_ole_initialized_key, (void*)(val))
# endif
2014-08-06 08:00:09 -04:00
2013-01-17 21:24:35 -05:00
static BOOL g_uninitialize_hooked = FALSE ;
2007-01-27 18:46:27 -05:00
static BOOL g_cp_installed = FALSE ;
2007-01-29 07:41:50 -05:00
static BOOL g_lcid_installed = FALSE ;
2002-06-01 08:34:30 -04:00
static HINSTANCE ghhctrl = NULL ;
static HINSTANCE gole32 = NULL ;
static FNCOCREATEINSTANCEEX * gCoCreateInstanceEx = NULL ;
2004-02-15 01:53:15 -05:00
static VALUE com_hash ;
2015-02-04 06:30:37 -05:00
static VALUE enc2cp_hash ;
2004-02-15 01:53:15 -05:00
static IDispatchVtbl com_vtbl ;
2007-01-29 07:41:50 -05:00
static UINT cWIN32OLE_cp = CP_ACP ;
2008-01-28 05:42:53 -05:00
static rb_encoding * cWIN32OLE_enc ;
2007-01-29 07:41:50 -05:00
static UINT g_cp_to_check = CP_ACP ;
static char g_lcid_to_check [ 8 + 1 ] ;
2005-04-15 09:05:01 -04:00
static VARTYPE g_nil_to = VT_ERROR ;
2008-07-02 11:35:04 -04:00
static IMessageFilterVtbl message_filter ;
static IMessageFilter imessage_filter = { & message_filter } ;
static IMessageFilter * previous_filter ;
2008-10-14 08:44:37 -04:00
# if defined(HAVE_TYPE_IMULTILANGUAGE2)
static IMultiLanguage2 * pIMultiLanguage = NULL ;
# elif defined(HAVE_TYPE_IMULTILANGUAGE)
static IMultiLanguage * pIMultiLanguage = NULL ;
# else
2009-02-09 06:11:57 -05:00
# define pIMultiLanguage NULL /* dummy */
2008-10-14 08:44:37 -04:00
# endif
2002-06-01 08:34:30 -04:00
struct oleparam {
DISPPARAMS dp ;
OLECHAR * * pNamedArgs ;
} ;
2007-01-27 18:46:27 -05:00
static HRESULT ( STDMETHODCALLTYPE QueryInterface ) ( IDispatch __RPC_FAR * , REFIID riid , void __RPC_FAR * __RPC_FAR * ppvObject ) ;
static ULONG ( STDMETHODCALLTYPE AddRef ) ( IDispatch __RPC_FAR * This ) ;
static ULONG ( STDMETHODCALLTYPE Release ) ( IDispatch __RPC_FAR * This ) ;
static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount ) ( IDispatch __RPC_FAR * This , UINT __RPC_FAR * pctinfo ) ;
static HRESULT ( STDMETHODCALLTYPE GetTypeInfo ) ( IDispatch __RPC_FAR * This , UINT iTInfo , LCID lcid , ITypeInfo __RPC_FAR * __RPC_FAR * ppTInfo ) ;
static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames ) ( IDispatch __RPC_FAR * This , REFIID riid , LPOLESTR __RPC_FAR * rgszNames , UINT cNames , LCID lcid , DISPID __RPC_FAR * rgDispId ) ;
static HRESULT ( STDMETHODCALLTYPE Invoke ) ( IDispatch __RPC_FAR * This , DISPID dispIdMember , REFIID riid , LCID lcid , WORD wFlags , DISPPARAMS __RPC_FAR * pDispParams , VARIANT __RPC_FAR * pVarResult , EXCEPINFO __RPC_FAR * pExcepInfo , UINT __RPC_FAR * puArgErr ) ;
static IDispatch * val2dispatch ( VALUE val ) ;
2009-07-21 03:27:08 -04:00
static double rbtime2vtdate ( VALUE tmobj ) ;
static VALUE vtdate2rbtime ( double date ) ;
2008-02-15 06:36:24 -05:00
static rb_encoding * ole_cp2encoding ( UINT cp ) ;
static UINT ole_encoding2cp ( rb_encoding * enc ) ;
2009-02-09 06:11:57 -05:00
NORETURN ( static void failed_load_conv51932 ( void ) ) ;
# ifndef pIMultiLanguage
static void load_conv_function51932 ( void ) ;
# endif
static UINT ole_init_cp ( void ) ;
2008-06-24 09:11:21 -04:00
static void ole_freeexceptinfo ( EXCEPINFO * pExInfo ) ;
2007-01-27 18:46:27 -05:00
static VALUE ole_excepinfo2msg ( EXCEPINFO * pExInfo ) ;
2014-12-01 06:03:13 -05:00
static void ole_free ( void * ptr ) ;
static size_t ole_size ( const void * ptr ) ;
2015-09-21 10:40:57 -04:00
static LPWSTR ole_mb2wc ( char * pm , int len , UINT cp ) ;
2014-04-19 20:12:15 -04:00
static VALUE ole_ary_m_entry ( VALUE val , LONG * pid ) ;
static VALUE is_all_index_under ( LONG * pid , long * pub , long dim ) ;
2014-08-13 08:46:23 -04:00
static void * get_ptr_of_variant ( VARIANT * pvar ) ;
2014-04-19 20:12:15 -04:00
static void ole_set_safe_array ( long n , SAFEARRAY * psa , LONG * pid , long * pub , VALUE val , long dim , VARTYPE vt ) ;
2007-02-03 00:41:03 -05:00
static long dimension ( VALUE val ) ;
static long ary_len_of_dim ( VALUE ary , long dim ) ;
2007-01-27 18:46:27 -05:00
static VALUE ole_set_member ( VALUE self , IDispatch * dispatch ) ;
static VALUE fole_s_allocate ( VALUE klass ) ;
static VALUE create_win32ole_object ( VALUE klass , IDispatch * pDispatch , int argc , VALUE * argv ) ;
2014-04-19 20:12:15 -04:00
static VALUE ary_new_dim ( VALUE myary , LONG * pid , LONG * plb , LONG dim ) ;
static void ary_store_dim ( VALUE myary , LONG * pid , LONG * plb , LONG dim , VALUE val ) ;
2007-01-27 18:46:27 -05:00
static void ole_const_load ( ITypeLib * pTypeLib , VALUE klass , VALUE self ) ;
static HRESULT clsid_from_remote ( VALUE host , VALUE com , CLSID * pclsid ) ;
2014-08-12 08:51:36 -04:00
static VALUE ole_create_dcom ( VALUE self , VALUE ole , VALUE host , VALUE others ) ;
2007-01-27 18:46:27 -05:00
static VALUE ole_bind_obj ( VALUE moniker , int argc , VALUE * argv , VALUE self ) ;
static VALUE fole_s_connect ( int argc , VALUE * argv , VALUE self ) ;
static VALUE fole_s_const_load ( int argc , VALUE * argv , VALUE self ) ;
static ULONG reference_count ( struct oledata * pole ) ;
static VALUE fole_s_reference_count ( VALUE self , VALUE obj ) ;
static VALUE fole_s_free ( VALUE self , VALUE obj ) ;
static HWND ole_show_help ( VALUE helpfile , VALUE helpcontext ) ;
static VALUE fole_s_show_help ( int argc , VALUE * argv , VALUE self ) ;
static VALUE fole_s_get_code_page ( VALUE self ) ;
static BOOL CALLBACK installed_code_page_proc ( LPTSTR str ) ;
static BOOL code_page_installed ( UINT cp ) ;
static VALUE fole_s_set_code_page ( VALUE self , VALUE vcp ) ;
2007-01-29 07:41:50 -05:00
static VALUE fole_s_get_locale ( VALUE self ) ;
static BOOL CALLBACK installed_lcid_proc ( LPTSTR str ) ;
static BOOL lcid_installed ( LCID lcid ) ;
static VALUE fole_s_set_locale ( VALUE self , VALUE vlcid ) ;
2007-01-27 18:46:27 -05:00
static VALUE fole_s_create_guid ( VALUE self ) ;
2010-01-23 06:02:17 -05:00
static VALUE fole_s_ole_initialize ( VALUE self ) ;
static VALUE fole_s_ole_uninitialize ( VALUE self ) ;
2007-01-27 18:46:27 -05:00
static VALUE fole_initialize ( int argc , VALUE * argv , VALUE self ) ;
2014-08-04 06:49:34 -04:00
static int hash2named_arg ( VALUE key , VALUE val , VALUE pop ) ;
2007-01-27 18:46:27 -05:00
static VALUE set_argv ( VARIANTARG * realargs , unsigned int beg , unsigned int end ) ;
static VALUE ole_invoke ( int argc , VALUE * argv , VALUE self , USHORT wFlags , BOOL is_bracket ) ;
static VALUE fole_invoke ( int argc , VALUE * argv , VALUE self ) ;
static VALUE ole_invoke2 ( VALUE self , VALUE dispid , VALUE args , VALUE types , USHORT dispkind ) ;
static VALUE fole_invoke2 ( VALUE self , VALUE dispid , VALUE args , VALUE types ) ;
static VALUE fole_getproperty2 ( VALUE self , VALUE dispid , VALUE args , VALUE types ) ;
static VALUE fole_setproperty2 ( VALUE self , VALUE dispid , VALUE args , VALUE types ) ;
static VALUE fole_setproperty_with_bracket ( int argc , VALUE * argv , VALUE self ) ;
static VALUE fole_setproperty ( int argc , VALUE * argv , VALUE self ) ;
static VALUE fole_getproperty_with_bracket ( int argc , VALUE * argv , VALUE self ) ;
static VALUE ole_propertyput ( VALUE self , VALUE property , VALUE value ) ;
static VALUE fole_free ( VALUE self ) ;
static VALUE ole_each_sub ( VALUE pEnumV ) ;
static VALUE ole_ienum_free ( VALUE pEnumV ) ;
static VALUE fole_each ( VALUE self ) ;
static VALUE fole_missing ( int argc , VALUE * argv , VALUE self ) ;
static HRESULT typeinfo_from_ole ( struct oledata * pole , ITypeInfo * * ppti ) ;
static VALUE ole_methods ( VALUE self , int mask ) ;
static VALUE fole_methods ( VALUE self ) ;
static VALUE fole_get_methods ( VALUE self ) ;
static VALUE fole_put_methods ( VALUE self ) ;
static VALUE fole_func_methods ( VALUE self ) ;
static VALUE fole_type ( VALUE self ) ;
static VALUE fole_typelib ( VALUE self ) ;
2007-02-10 06:29:49 -05:00
static VALUE fole_query_interface ( VALUE self , VALUE str_iid ) ;
2008-07-04 21:01:01 -04:00
static VALUE fole_respond_to ( VALUE self , VALUE method ) ;
2007-01-27 18:46:27 -05:00
static VALUE ole_usertype2val ( ITypeInfo * pTypeInfo , TYPEDESC * pTypeDesc , VALUE typedetails ) ;
static VALUE ole_ptrtype2val ( ITypeInfo * pTypeInfo , TYPEDESC * pTypeDesc , VALUE typedetails ) ;
static VALUE fole_method_help ( VALUE self , VALUE cmdname ) ;
2007-03-16 09:24:06 -04:00
static VALUE fole_activex_initialize ( VALUE self ) ;
2014-08-11 17:20:10 -04:00
2014-12-02 07:34:52 -05:00
static void com_hash_free ( void * ptr ) ;
static void com_hash_mark ( void * ptr ) ;
static size_t com_hash_size ( const void * ptr ) ;
2014-12-01 06:03:13 -05:00
static const rb_data_type_t ole_datatype = {
" win32ole " ,
{ NULL , ole_free , ole_size , } ,
0 , 0 , RUBY_TYPED_FREE_IMMEDIATELY
} ;
2015-02-04 06:30:37 -05:00
static const rb_data_type_t win32ole_hash_datatype = {
" win32ole_hash " ,
2014-12-02 07:34:52 -05:00
{ com_hash_mark , com_hash_free , com_hash_size , } ,
0 , 0 , RUBY_TYPED_FREE_IMMEDIATELY
} ;
2008-07-02 11:35:04 -04:00
static HRESULT ( STDMETHODCALLTYPE mf_QueryInterface ) (
IMessageFilter __RPC_FAR * This ,
/* [in] */ REFIID riid ,
/* [iid_is][out] */ void __RPC_FAR * __RPC_FAR * ppvObject )
{
if ( MEMCMP ( riid , & IID_IUnknown , GUID , 1 ) = = 0
| | MEMCMP ( riid , & IID_IMessageFilter , GUID , 1 ) = = 0 )
{
* ppvObject = & message_filter ;
return S_OK ;
}
return E_NOINTERFACE ;
}
2010-04-22 04:04:13 -04:00
static ULONG ( STDMETHODCALLTYPE mf_AddRef ) (
2008-07-02 11:35:04 -04:00
IMessageFilter __RPC_FAR * This )
{
return 1 ;
}
2010-04-22 04:04:13 -04:00
static ULONG ( STDMETHODCALLTYPE mf_Release ) (
2008-07-02 11:35:04 -04:00
IMessageFilter __RPC_FAR * This )
{
return 1 ;
}
static DWORD ( STDMETHODCALLTYPE mf_HandleInComingCall ) (
IMessageFilter __RPC_FAR * pThis ,
DWORD dwCallType , //Type of incoming call
HTASK threadIDCaller , //Task handle calling this task
DWORD dwTickCount , //Elapsed tick count
LPINTERFACEINFO lpInterfaceInfo //Pointer to INTERFACEINFO structure
)
{
# ifdef DEBUG_MESSAGEFILTER
printf ( " incoming %08X, %08X, %d \n " , dwCallType , threadIDCaller , dwTickCount ) ;
fflush ( stdout ) ;
# endif
switch ( dwCallType )
{
case CALLTYPE_ASYNC :
case CALLTYPE_TOPLEVEL_CALLPENDING :
case CALLTYPE_ASYNC_CALLPENDING :
if ( rb_during_gc ( ) ) {
return SERVERCALL_RETRYLATER ;
}
break ;
default :
break ;
}
if ( previous_filter ) {
return previous_filter - > lpVtbl - > HandleInComingCall ( previous_filter ,
dwCallType ,
threadIDCaller ,
dwTickCount ,
lpInterfaceInfo ) ;
}
return SERVERCALL_ISHANDLED ;
}
static DWORD ( STDMETHODCALLTYPE mf_RetryRejectedCall ) (
IMessageFilter * pThis ,
HTASK threadIDCallee , //Server task handle
DWORD dwTickCount , //Elapsed tick count
DWORD dwRejectType //Returned rejection message
)
{
if ( previous_filter ) {
return previous_filter - > lpVtbl - > RetryRejectedCall ( previous_filter ,
threadIDCallee ,
dwTickCount ,
dwRejectType ) ;
}
return 1000 ;
}
static DWORD ( STDMETHODCALLTYPE mf_MessagePending ) (
IMessageFilter * pThis ,
HTASK threadIDCallee , //Called applications task handle
DWORD dwTickCount , //Elapsed tick count
DWORD dwPendingType //Call type
)
{
if ( rb_during_gc ( ) ) {
return PENDINGMSG_WAITNOPROCESS ;
}
if ( previous_filter ) {
return previous_filter - > lpVtbl - > MessagePending ( previous_filter ,
threadIDCallee ,
dwTickCount ,
dwPendingType ) ;
}
return PENDINGMSG_WAITNOPROCESS ;
}
2010-04-22 04:04:13 -04:00
2004-02-15 01:53:15 -05:00
typedef struct _Win32OLEIDispatch
{
IDispatch dispatch ;
ULONG refcount ;
VALUE obj ;
} Win32OLEIDispatch ;
2010-04-22 04:04:13 -04:00
static HRESULT ( STDMETHODCALLTYPE QueryInterface ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This ,
/* [in] */ REFIID riid ,
/* [iid_is][out] */ void __RPC_FAR * __RPC_FAR * ppvObject )
{
if ( MEMCMP ( riid , & IID_IUnknown , GUID , 1 ) = = 0
| | MEMCMP ( riid , & IID_IDispatch , GUID , 1 ) = = 0 )
{
Win32OLEIDispatch * p = ( Win32OLEIDispatch * ) This ;
p - > refcount + + ;
* ppvObject = This ;
return S_OK ;
}
return E_NOINTERFACE ;
}
2010-04-22 04:04:13 -04:00
static ULONG ( STDMETHODCALLTYPE AddRef ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This )
{
Win32OLEIDispatch * p = ( Win32OLEIDispatch * ) This ;
return + + ( p - > refcount ) ;
}
2010-04-22 04:04:13 -04:00
static ULONG ( STDMETHODCALLTYPE Release ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This )
{
Win32OLEIDispatch * p = ( Win32OLEIDispatch * ) This ;
ULONG u = - - ( p - > refcount ) ;
if ( u = = 0 ) {
st_data_t key = p - > obj ;
st_delete ( DATA_PTR ( com_hash ) , & key , 0 ) ;
free ( p ) ;
}
return u ;
}
2010-04-22 04:04:13 -04:00
static HRESULT ( STDMETHODCALLTYPE GetTypeInfoCount ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This ,
/* [out] */ UINT __RPC_FAR * pctinfo )
{
return E_NOTIMPL ;
}
2010-04-22 04:04:13 -04:00
static HRESULT ( STDMETHODCALLTYPE GetTypeInfo ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This ,
/* [in] */ UINT iTInfo ,
/* [in] */ LCID lcid ,
/* [out] */ ITypeInfo __RPC_FAR * __RPC_FAR * ppTInfo )
{
return E_NOTIMPL ;
}
2010-04-22 04:04:13 -04:00
static HRESULT ( STDMETHODCALLTYPE GetIDsOfNames ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This ,
/* [in] */ REFIID riid ,
/* [size_is][in] */ LPOLESTR __RPC_FAR * rgszNames ,
/* [in] */ UINT cNames ,
/* [in] */ LCID lcid ,
/* [size_is][out] */ DISPID __RPC_FAR * rgDispId )
{
2005-08-13 08:22:12 -04:00
/*
2004-02-15 01:53:15 -05:00
Win32OLEIDispatch * p = ( Win32OLEIDispatch * ) This ;
2005-08-13 08:22:12 -04:00
*/
2004-02-15 01:53:15 -05:00
char * psz = ole_wc2mb ( * rgszNames ) ; // support only one method
2015-09-21 11:29:20 -04:00
ID nameid = rb_check_id_cstr ( psz , ( long ) strlen ( psz ) , cWIN32OLE_enc ) ;
2004-02-15 01:53:15 -05:00
free ( psz ) ;
2013-08-23 10:09:49 -04:00
if ( ( ID ) ( DISPID ) nameid ! = nameid ) return E_NOINTERFACE ;
* rgDispId = ( DISPID ) nameid ;
2004-02-15 01:53:15 -05:00
return S_OK ;
}
2010-04-22 04:04:13 -04:00
static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke ) (
2004-02-15 01:53:15 -05:00
IDispatch __RPC_FAR * This ,
/* [in] */ DISPID dispIdMember ,
/* [in] */ REFIID riid ,
/* [in] */ LCID lcid ,
/* [in] */ WORD wFlags ,
/* [out][in] */ DISPPARAMS __RPC_FAR * pDispParams ,
/* [out] */ VARIANT __RPC_FAR * pVarResult ,
/* [out] */ EXCEPINFO __RPC_FAR * pExcepInfo ,
/* [out] */ UINT __RPC_FAR * puArgErr )
{
VALUE v ;
int i ;
int args = pDispParams - > cArgs ;
Win32OLEIDispatch * p = ( Win32OLEIDispatch * ) This ;
VALUE * parg = ALLOCA_N ( VALUE , args ) ;
2013-08-23 10:09:49 -04:00
ID mid = ( ID ) dispIdMember ;
2004-02-15 01:53:15 -05:00
for ( i = 0 ; i < args ; i + + ) {
* ( parg + i ) = ole_variant2val ( & pDispParams - > rgvarg [ args - i - 1 ] ) ;
}
if ( dispIdMember = = DISPID_VALUE ) {
if ( wFlags = = DISPATCH_METHOD ) {
2013-08-23 10:09:49 -04:00
mid = rb_intern ( " call " ) ;
2004-02-15 01:53:15 -05:00
} else if ( wFlags & DISPATCH_PROPERTYGET ) {
2013-08-23 10:09:49 -04:00
mid = rb_intern ( " value " ) ;
2004-02-15 01:53:15 -05:00
}
}
2013-08-23 10:09:49 -04:00
v = rb_funcall2 ( p - > obj , mid , args , parg ) ;
2004-02-15 01:53:15 -05:00
ole_val2variant ( v , pVarResult ) ;
return S_OK ;
}
2014-08-06 08:00:09 -04:00
BOOL
2014-09-30 01:25:32 -04:00
ole_initialized ( void )
2014-08-06 08:00:09 -04:00
{
return g_ole_initialized ;
}
2004-02-15 01:53:15 -05:00
static IDispatch *
2006-04-30 09:11:12 -04:00
val2dispatch ( VALUE val )
2004-02-15 01:53:15 -05:00
{
struct st_table * tbl = DATA_PTR ( com_hash ) ;
Win32OLEIDispatch * pdisp ;
st_data_t data ;
if ( st_lookup ( tbl , val , & data ) ) {
pdisp = ( Win32OLEIDispatch * ) ( data & ~ FIXNUM_FLAG ) ;
pdisp - > refcount + + ;
}
else {
pdisp = ALLOC ( Win32OLEIDispatch ) ;
pdisp - > dispatch . lpVtbl = & com_vtbl ;
pdisp - > refcount = 1 ;
pdisp - > obj = val ;
st_insert ( tbl , val , ( VALUE ) pdisp | FIXNUM_FLAG ) ;
}
return & pdisp - > dispatch ;
}
2002-06-01 08:34:30 -04:00
static double
2009-07-21 03:27:08 -04:00
rbtime2vtdate ( VALUE tmobj )
2002-06-01 08:34:30 -04:00
{
2009-07-21 03:27:08 -04:00
SYSTEMTIME st ;
2014-08-27 06:57:28 -04:00
double t ;
2014-09-01 07:16:57 -04:00
double nsec ;
2009-07-21 03:27:08 -04:00
st . wYear = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " year " ) , 0 ) ) ;
st . wMonth = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " month " ) , 0 ) ) ;
st . wDay = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " mday " ) , 0 ) ) ;
st . wHour = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " hour " ) , 0 ) ) ;
st . wMinute = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " min " ) , 0 ) ) ;
st . wSecond = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " sec " ) , 0 ) ) ;
2014-09-20 22:18:37 -04:00
st . wMilliseconds = 0 ;
2009-07-21 03:27:08 -04:00
SystemTimeToVariantTime ( & st , & t ) ;
2014-09-01 07:16:57 -04:00
/*
* Unfortunately SystemTimeToVariantTime function always ignores the
* wMilliseconds of SYSTEMTIME struct .
* So , we need to calculate milliseconds by ourselves .
*/
nsec = FIX2INT ( rb_funcall ( tmobj , rb_intern ( " nsec " ) , 0 ) ) ;
nsec / = 1000000.0 ;
nsec / = ( 24.0 * 3600.0 ) ;
nsec / = 1000 ;
return t + nsec ;
2002-06-01 08:34:30 -04:00
}
static VALUE
2009-07-21 03:27:08 -04:00
vtdate2rbtime ( double date )
2002-06-01 08:34:30 -04:00
{
2009-07-21 03:27:08 -04:00
SYSTEMTIME st ;
VALUE v ;
2014-08-27 06:57:28 -04:00
double msec ;
2014-09-20 22:18:37 -04:00
double sec ;
2009-07-21 03:27:08 -04:00
VariantTimeToSystemTime ( date , & st ) ;
v = rb_funcall ( rb_cTime , rb_intern ( " new " ) , 6 ,
INT2FIX ( st . wYear ) ,
INT2FIX ( st . wMonth ) ,
INT2FIX ( st . wDay ) ,
INT2FIX ( st . wHour ) ,
INT2FIX ( st . wMinute ) ,
INT2FIX ( st . wSecond ) ) ;
2014-09-20 22:18:37 -04:00
st . wYear = FIX2INT ( rb_funcall ( v , rb_intern ( " year " ) , 0 ) ) ;
st . wMonth = FIX2INT ( rb_funcall ( v , rb_intern ( " month " ) , 0 ) ) ;
st . wDay = FIX2INT ( rb_funcall ( v , rb_intern ( " mday " ) , 0 ) ) ;
st . wHour = FIX2INT ( rb_funcall ( v , rb_intern ( " hour " ) , 0 ) ) ;
st . wMinute = FIX2INT ( rb_funcall ( v , rb_intern ( " min " ) , 0 ) ) ;
st . wSecond = FIX2INT ( rb_funcall ( v , rb_intern ( " sec " ) , 0 ) ) ;
st . wMilliseconds = 0 ;
SystemTimeToVariantTime ( & st , & sec ) ;
2014-08-27 06:57:28 -04:00
/*
* Unfortunately VariantTimeToSystemTime always ignores the
* wMilliseconds of SYSTEMTIME struct ( The wMilliseconds is 0 ) .
* So , we need to calculate milliseconds by ourselves .
*/
2014-09-20 22:18:37 -04:00
msec = date - sec ;
2014-08-27 06:57:28 -04:00
msec * = 24 * 60 ;
msec - = floor ( msec ) ;
msec * = 60 ;
2014-09-20 22:18:37 -04:00
if ( msec > = 59 ) {
msec - = 60 ;
}
2014-08-27 06:57:28 -04:00
if ( msec ! = 0 ) {
return rb_funcall ( v , rb_intern ( " + " ) , 1 , rb_float_new ( msec ) ) ;
2009-07-21 03:27:08 -04:00
}
return v ;
2002-06-01 08:34:30 -04:00
}
2008-02-15 06:36:24 -05:00
# define ENC_MACHING_CP(enc,encname,cp) if(strcasecmp(rb_enc_name((enc)),(encname)) == 0) return cp
static UINT ole_encoding2cp ( rb_encoding * enc )
{
/*
2010-04-22 04:04:13 -04:00
* Is there any better solution to convert
2008-02-15 06:36:24 -05:00
* Ruby encoding to Windows codepage ? ? ?
*/
ENC_MACHING_CP ( enc , " Big5 " , 950 ) ;
ENC_MACHING_CP ( enc , " CP51932 " , 51932 ) ;
ENC_MACHING_CP ( enc , " CP850 " , 850 ) ;
ENC_MACHING_CP ( enc , " CP852 " , 852 ) ;
ENC_MACHING_CP ( enc , " CP855 " , 855 ) ;
ENC_MACHING_CP ( enc , " CP949 " , 949 ) ;
2010-04-22 04:04:13 -04:00
ENC_MACHING_CP ( enc , " EUC-JP " , 20932 ) ;
2008-02-15 06:36:24 -05:00
ENC_MACHING_CP ( enc , " EUC-KR " , 51949 ) ;
ENC_MACHING_CP ( enc , " EUC-TW " , 51950 ) ;
ENC_MACHING_CP ( enc , " GB18030 " , 54936 ) ;
2010-10-15 22:14:32 -04:00
ENC_MACHING_CP ( enc , " GB2312 " , 20936 ) ;
2008-02-15 06:36:24 -05:00
ENC_MACHING_CP ( enc , " GBK " , 936 ) ;
ENC_MACHING_CP ( enc , " IBM437 " , 437 ) ;
ENC_MACHING_CP ( enc , " IBM737 " , 737 ) ;
ENC_MACHING_CP ( enc , " IBM775 " , 775 ) ;
ENC_MACHING_CP ( enc , " IBM852 " , 852 ) ;
ENC_MACHING_CP ( enc , " IBM855 " , 855 ) ;
ENC_MACHING_CP ( enc , " IBM857 " , 857 ) ;
ENC_MACHING_CP ( enc , " IBM860 " , 860 ) ;
ENC_MACHING_CP ( enc , " IBM861 " , 861 ) ;
ENC_MACHING_CP ( enc , " IBM862 " , 862 ) ;
ENC_MACHING_CP ( enc , " IBM863 " , 863 ) ;
ENC_MACHING_CP ( enc , " IBM864 " , 864 ) ;
ENC_MACHING_CP ( enc , " IBM865 " , 865 ) ;
ENC_MACHING_CP ( enc , " IBM866 " , 866 ) ;
ENC_MACHING_CP ( enc , " IBM869 " , 869 ) ;
ENC_MACHING_CP ( enc , " ISO-2022-JP " , 50220 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-1 " , 28591 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-15 " , 28605 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-2 " , 28592 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-3 " , 28593 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-4 " , 28594 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-5 " , 28595 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-6 " , 28596 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-7 " , 28597 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-8 " , 28598 ) ;
ENC_MACHING_CP ( enc , " ISO-8859-9 " , 28599 ) ;
ENC_MACHING_CP ( enc , " KOI8-R " , 20866 ) ;
ENC_MACHING_CP ( enc , " KOI8-U " , 21866 ) ;
ENC_MACHING_CP ( enc , " Shift_JIS " , 932 ) ;
ENC_MACHING_CP ( enc , " UTF-16BE " , 1201 ) ;
ENC_MACHING_CP ( enc , " UTF-16LE " , 1200 ) ;
ENC_MACHING_CP ( enc , " UTF-7 " , 65000 ) ;
ENC_MACHING_CP ( enc , " UTF-8 " , 65001 ) ;
ENC_MACHING_CP ( enc , " Windows-1250 " , 1250 ) ;
ENC_MACHING_CP ( enc , " Windows-1251 " , 1251 ) ;
ENC_MACHING_CP ( enc , " Windows-1252 " , 1252 ) ;
ENC_MACHING_CP ( enc , " Windows-1253 " , 1253 ) ;
ENC_MACHING_CP ( enc , " Windows-1254 " , 1254 ) ;
ENC_MACHING_CP ( enc , " Windows-1255 " , 1255 ) ;
ENC_MACHING_CP ( enc , " Windows-1256 " , 1256 ) ;
ENC_MACHING_CP ( enc , " Windows-1257 " , 1257 ) ;
ENC_MACHING_CP ( enc , " Windows-1258 " , 1258 ) ;
ENC_MACHING_CP ( enc , " Windows-31J " , 932 ) ;
ENC_MACHING_CP ( enc , " Windows-874 " , 874 ) ;
ENC_MACHING_CP ( enc , " eucJP-ms " , 20932 ) ;
return CP_ACP ;
}
2008-10-12 05:06:45 -04:00
static void
2009-02-09 06:11:57 -05:00
failed_load_conv51932 ( void )
{
rb_raise ( eWIN32OLERuntimeError , " fail to load convert function for CP51932 " ) ;
}
# ifndef pIMultiLanguage
static void
load_conv_function51932 ( void )
2008-10-12 05:06:45 -04:00
{
2008-10-14 08:44:37 -04:00
HRESULT hr = E_NOINTERFACE ;
2008-10-12 05:06:45 -04:00
void * p ;
2008-10-14 08:44:37 -04:00
if ( ! pIMultiLanguage ) {
# if defined(HAVE_TYPE_IMULTILANGUAGE2)
2008-10-12 05:06:45 -04:00
hr = CoCreateInstance ( & CLSID_CMultiLanguage , NULL , CLSCTX_INPROC_SERVER ,
& IID_IMultiLanguage2 , & p ) ;
2008-10-14 08:44:37 -04:00
# elif defined(HAVE_TYPE_IMULTILANGUAGE)
hr = CoCreateInstance ( & CLSID_CMultiLanguage , NULL , CLSCTX_INPROC_SERVER ,
& IID_IMultiLanguage , & p ) ;
# endif
2008-10-12 05:06:45 -04:00
if ( FAILED ( hr ) ) {
2009-02-09 06:11:57 -05:00
failed_load_conv51932 ( ) ;
2008-10-12 05:06:45 -04:00
}
2008-10-14 08:44:37 -04:00
pIMultiLanguage = p ;
2008-10-12 05:06:45 -04:00
}
}
2014-12-26 01:09:11 -05:00
# define need_conv_function51932() (load_conv_function51932(), 1)
2009-02-09 06:11:57 -05:00
# else
# define load_conv_function51932() failed_load_conv51932()
2014-12-26 01:09:11 -05:00
# define need_conv_function51932() (failed_load_conv51932(), 0)
2009-02-09 06:11:57 -05:00
# endif
2014-12-26 01:09:11 -05:00
# define conv_51932(cp) ((cp) == 51932 && need_conv_function51932())
2008-10-12 05:06:45 -04:00
static void
set_ole_codepage ( UINT cp )
{
if ( code_page_installed ( cp ) ) {
cWIN32OLE_cp = cp ;
} else {
switch ( cp ) {
case CP_ACP :
case CP_OEMCP :
case CP_MACCP :
case CP_THREAD_ACP :
case CP_SYMBOL :
case CP_UTF7 :
case CP_UTF8 :
2009-02-09 06:11:57 -05:00
cWIN32OLE_cp = cp ;
break ;
2008-10-12 05:06:45 -04:00
case 51932 :
cWIN32OLE_cp = cp ;
2009-02-09 06:11:57 -05:00
load_conv_function51932 ( ) ;
2008-10-12 05:06:45 -04:00
break ;
default :
rb_raise ( eWIN32OLERuntimeError , " codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8, or installed codepage. " ) ;
break ;
}
}
cWIN32OLE_enc = ole_cp2encoding ( cWIN32OLE_cp ) ;
}
2008-02-15 06:36:24 -05:00
static UINT
2009-02-09 06:11:57 -05:00
ole_init_cp ( void )
2008-02-15 06:36:24 -05:00
{
UINT cp ;
rb_encoding * encdef ;
2008-10-08 08:05:18 -04:00
encdef = rb_default_internal_encoding ( ) ;
if ( ! encdef ) {
encdef = rb_default_external_encoding ( ) ;
}
2008-02-15 06:36:24 -05:00
cp = ole_encoding2cp ( encdef ) ;
2008-10-12 05:06:45 -04:00
set_ole_codepage ( cp ) ;
2008-02-23 07:36:51 -05:00
return cp ;
2008-02-15 06:36:24 -05:00
}
2008-01-28 05:42:53 -05:00
struct myCPINFOEX {
UINT MaxCharSize ;
BYTE DefaultChar [ 2 ] ;
BYTE LeadByte [ 12 ] ;
WCHAR UnicodeDefaultChar ;
UINT CodePage ;
char CodePageName [ MAX_PATH ] ;
} ;
static rb_encoding *
ole_cp2encoding ( UINT cp )
{
static BOOL ( * pGetCPInfoEx ) ( UINT , DWORD , struct myCPINFOEX * ) = NULL ;
struct myCPINFOEX * buf ;
VALUE enc_name ;
char * enc_cstr ;
int idx ;
if ( ! code_page_installed ( cp ) ) {
switch ( cp ) {
case CP_ACP :
cp = GetACP ( ) ;
break ;
case CP_OEMCP :
cp = GetOEMCP ( ) ;
break ;
case CP_MACCP :
case CP_THREAD_ACP :
if ( ! pGetCPInfoEx ) {
2008-07-23 18:01:36 -04:00
pGetCPInfoEx = ( BOOL ( * ) ( UINT , DWORD , struct myCPINFOEX * ) )
2008-01-28 05:42:53 -05:00
GetProcAddress ( GetModuleHandle ( " kernel32 " ) , " GetCPInfoEx " ) ;
if ( ! pGetCPInfoEx ) {
pGetCPInfoEx = ( void * ) - 1 ;
}
}
buf = ALLOCA_N ( struct myCPINFOEX , 1 ) ;
ZeroMemory ( buf , sizeof ( struct myCPINFOEX ) ) ;
if ( pGetCPInfoEx = = ( void * ) - 1 | | ! pGetCPInfoEx ( cp , 0 , buf ) ) {
rb_raise ( eWIN32OLERuntimeError , " cannot map codepage to encoding. " ) ;
break ; /* never reach here */
}
cp = buf - > CodePage ;
break ;
case CP_SYMBOL :
case CP_UTF7 :
case CP_UTF8 :
2008-10-12 05:06:45 -04:00
break ;
2010-04-22 04:04:13 -04:00
case 51932 :
2008-10-12 05:06:45 -04:00
load_conv_function51932 ( ) ;
2008-01-28 05:42:53 -05:00
break ;
default :
rb_raise ( eWIN32OLERuntimeError , " codepage should be WIN32OLE::CP_ACP, WIN32OLE::CP_OEMCP, WIN32OLE::CP_MACCP, WIN32OLE::CP_THREAD_ACP, WIN32OLE::CP_SYMBOL, WIN32OLE::CP_UTF7, WIN32OLE::CP_UTF8, or installed codepage. " ) ;
break ;
}
}
enc_name = rb_sprintf ( " CP%d " , cp ) ;
idx = rb_enc_find_index ( enc_cstr = StringValueCStr ( enc_name ) ) ;
if ( idx < 0 )
idx = rb_define_dummy_encoding ( enc_cstr ) ;
return rb_enc_from_index ( idx ) ;
}
2015-09-21 10:52:26 -04:00
# ifndef pIMultiLanguage
static HRESULT
ole_ml_wc2mb_conv0 ( LPWSTR pw , LPSTR pm , UINT * size )
{
DWORD dw = 0 ;
return pIMultiLanguage - > lpVtbl - > ConvertStringFromUnicode ( pIMultiLanguage ,
& dw , cWIN32OLE_cp , pw , NULL , pm , size ) ;
}
# define ole_ml_wc2mb_conv(pw, pm, size, onfailure) do { \
HRESULT hr = ole_ml_wc2mb_conv0 ( pw , pm , & size ) ; \
if ( FAILED ( hr ) ) { \
onfailure ; \
ole_raise ( hr , eWIN32OLERuntimeError , " fail to convert Unicode to CP%d " , cWIN32OLE_cp ) ; \
} \
} while ( 0 )
# endif
# define ole_wc2mb_conv(pw, pm, size) WideCharToMultiByte(cWIN32OLE_cp, 0, (pw), -1, (pm), (size), NULL, NULL)
2002-06-01 08:34:30 -04:00
static char *
2013-08-23 04:17:59 -04:00
ole_wc2mb_alloc ( LPWSTR pw , char * ( alloc ) ( UINT size , void * arg ) , void * arg )
2002-06-01 08:34:30 -04:00
{
LPSTR pm ;
2010-11-11 07:30:39 -05:00
UINT size = 0 ;
2009-02-09 06:11:57 -05:00
if ( conv_51932 ( cWIN32OLE_cp ) ) {
# ifndef pIMultiLanguage
2015-09-21 10:52:26 -04:00
ole_ml_wc2mb_conv ( pw , NULL , size , { } ) ;
2013-08-23 04:17:59 -04:00
pm = alloc ( size , arg ) ;
2015-09-21 10:52:26 -04:00
if ( size ) ole_ml_wc2mb_conv ( pw , pm , size , xfree ( pm ) ) ;
2008-10-12 05:06:45 -04:00
pm [ size ] = ' \0 ' ;
2014-12-26 01:09:11 -05:00
return pm ;
2009-02-09 06:11:57 -05:00
# endif
2008-10-12 05:06:45 -04:00
}
2015-09-21 10:52:26 -04:00
size = ole_wc2mb_conv ( pw , NULL , 0 ) ;
pm = alloc ( size , arg ) ;
if ( size ) ole_wc2mb_conv ( pw , pm , size ) ;
pm [ size ] = ' \0 ' ;
2002-06-01 08:34:30 -04:00
return pm ;
2010-04-22 04:04:13 -04:00
}
2002-06-01 08:34:30 -04:00
2013-08-23 04:17:59 -04:00
static char *
ole_alloc_str ( UINT size , void * arg )
{
return ALLOC_N ( char , size + 1 ) ;
}
2014-08-15 07:36:12 -04:00
char *
2013-08-23 04:17:59 -04:00
ole_wc2mb ( LPWSTR pw )
{
return ole_wc2mb_alloc ( pw , ole_alloc_str , NULL ) ;
}
2008-06-24 09:11:21 -04:00
static void
ole_freeexceptinfo ( EXCEPINFO * pExInfo )
{
SysFreeString ( pExInfo - > bstrDescription ) ;
SysFreeString ( pExInfo - > bstrSource ) ;
SysFreeString ( pExInfo - > bstrHelpFile ) ;
}
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
ole_excepinfo2msg ( EXCEPINFO * pExInfo )
2002-06-01 08:34:30 -04:00
{
char error_code [ 40 ] ;
char * pSource = NULL ;
char * pDescription = NULL ;
VALUE error_msg ;
if ( pExInfo - > pfnDeferredFillIn ! = NULL ) {
( * pExInfo - > pfnDeferredFillIn ) ( pExInfo ) ;
}
if ( pExInfo - > bstrSource ! = NULL ) {
pSource = ole_wc2mb ( pExInfo - > bstrSource ) ;
}
if ( pExInfo - > bstrDescription ! = NULL ) {
pDescription = ole_wc2mb ( pExInfo - > bstrDescription ) ;
}
if ( pExInfo - > wCode = = 0 ) {
2014-04-23 00:14:42 -04:00
sprintf ( error_code , " \n OLE error code:%lX in " , ( unsigned long ) pExInfo - > scode ) ;
2002-06-01 08:34:30 -04:00
}
else {
sprintf ( error_code , " \n OLE error code:%u in " , pExInfo - > wCode ) ;
}
error_msg = rb_str_new2 ( error_code ) ;
if ( pSource ! = NULL ) {
2013-08-23 04:17:50 -04:00
rb_str_cat2 ( error_msg , pSource ) ;
2002-06-01 08:34:30 -04:00
}
else {
rb_str_cat ( error_msg , " <Unknown> " , 9 ) ;
}
rb_str_cat2 ( error_msg , " \n " ) ;
if ( pDescription ! = NULL ) {
rb_str_cat2 ( error_msg , pDescription ) ;
}
else {
rb_str_cat2 ( error_msg , " <No Description> " ) ;
}
if ( pSource ) free ( pSource ) ;
if ( pDescription ) free ( pDescription ) ;
2008-06-24 09:11:21 -04:00
ole_freeexceptinfo ( pExInfo ) ;
2002-06-01 08:34:30 -04:00
return error_msg ;
}
void
2013-01-17 00:06:28 -05:00
ole_uninitialize ( void )
2002-06-01 08:34:30 -04:00
{
2013-01-17 21:24:35 -05:00
if ( ! g_ole_initialized ) return ;
2002-06-01 08:34:30 -04:00
OleUninitialize ( ) ;
2013-01-17 21:23:37 -05:00
g_ole_initialized_set ( FALSE ) ;
2002-06-01 08:34:30 -04:00
}
2013-01-17 21:24:35 -05:00
static void
ole_uninitialize_hook ( rb_event_flag_t evflag , VALUE data , VALUE self , ID mid , VALUE klass )
{
ole_uninitialize ( ) ;
}
2014-08-06 08:00:09 -04:00
void
2013-01-17 00:06:28 -05:00
ole_initialize ( void )
2002-06-01 08:34:30 -04:00
{
HRESULT hr ;
2010-04-22 04:04:13 -04:00
2013-01-17 21:24:35 -05:00
if ( ! g_uninitialize_hooked ) {
rb_add_event_hook ( ole_uninitialize_hook , RUBY_EVENT_THREAD_END , Qnil ) ;
g_uninitialize_hooked = TRUE ;
}
2007-01-27 18:46:27 -05:00
if ( g_ole_initialized = = FALSE ) {
2002-06-01 08:34:30 -04:00
hr = OleInitialize ( NULL ) ;
if ( FAILED ( hr ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " fail: OLE initialize " ) ;
2002-06-01 08:34:30 -04:00
}
2013-01-17 21:23:37 -05:00
g_ole_initialized_set ( TRUE ) ;
2008-07-02 11:35:04 -04:00
hr = CoRegisterMessageFilter ( & imessage_filter , & previous_filter ) ;
if ( FAILED ( hr ) ) {
previous_filter = NULL ;
ole_raise ( hr , rb_eRuntimeError , " fail: install OLE MessageFilter " ) ;
}
2002-06-01 08:34:30 -04:00
}
}
static void
2014-12-01 06:03:13 -05:00
ole_free ( void * ptr )
2002-06-01 08:34:30 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = ptr ;
2002-06-01 08:34:30 -04:00
OLE_FREE ( pole - > pDispatch ) ;
2007-01-13 09:40:54 -05:00
free ( pole ) ;
2002-06-01 08:34:30 -04:00
}
2014-12-01 06:03:13 -05:00
static size_t ole_size ( const void * ptr )
{
return ptr ? sizeof ( struct oledata ) : 0 ;
}
struct oledata *
oledata_get_struct ( VALUE ole )
{
struct oledata * pole ;
TypedData_Get_Struct ( ole , struct oledata , & ole_datatype , pole ) ;
return pole ;
}
2014-08-06 08:00:09 -04:00
LPWSTR
2008-06-27 19:43:57 -04:00
ole_vstr2wc ( VALUE vstr )
{
rb_encoding * enc ;
int cp ;
LPWSTR pw ;
st_data_t data ;
2015-02-04 06:30:37 -05:00
struct st_table * tbl = DATA_PTR ( enc2cp_hash ) ;
2015-12-13 04:19:20 -05:00
/* do not type-conversion here to prevent from other arguments
* changing ( if exist ) */
Check_Type ( vstr , T_STRING ) ;
2015-12-26 19:48:20 -05:00
if ( RSTRING_LEN ( vstr ) = = 0 ) {
return NULL ;
}
2015-12-13 04:19:20 -05:00
2008-06-27 19:43:57 -04:00
enc = rb_enc_get ( vstr ) ;
2008-10-12 05:06:45 -04:00
2015-02-04 06:30:37 -05:00
if ( st_lookup ( tbl , ( VALUE ) enc | FIXNUM_FLAG , & data ) ) {
cp = FIX2INT ( ( VALUE ) data ) ;
2008-06-27 19:43:57 -04:00
} else {
cp = ole_encoding2cp ( enc ) ;
if ( code_page_installed ( cp ) | |
cp = = CP_ACP | |
cp = = CP_OEMCP | |
cp = = CP_MACCP | |
cp = = CP_THREAD_ACP | |
cp = = CP_SYMBOL | |
cp = = CP_UTF7 | |
2008-10-12 05:06:45 -04:00
cp = = CP_UTF8 | |
cp = = 51932 ) {
2015-02-04 06:30:37 -05:00
st_insert ( tbl , ( VALUE ) enc | FIXNUM_FLAG , INT2FIX ( cp ) ) ;
2008-06-27 19:43:57 -04:00
} else {
rb_raise ( eWIN32OLERuntimeError , " not installed Windows codepage(%d) according to `%s' " , cp , rb_enc_name ( enc ) ) ;
}
}
2015-09-21 10:40:57 -04:00
pw = ole_mb2wc ( RSTRING_PTR ( vstr ) , RSTRING_LENINT ( vstr ) , cp ) ;
RB_GC_GUARD ( vstr ) ;
2008-06-27 19:43:57 -04:00
return pw ;
}
2002-06-01 08:34:30 -04:00
static LPWSTR
2015-09-21 10:40:57 -04:00
ole_mb2wc ( char * pm , int len , UINT cp )
2002-06-01 08:34:30 -04:00
{
2010-11-11 07:30:39 -05:00
UINT size = 0 ;
2002-06-01 08:34:30 -04:00
LPWSTR pw ;
2008-10-12 05:06:45 -04:00
2015-09-21 10:40:57 -04:00
if ( conv_51932 ( cp ) ) {
2009-02-09 06:11:57 -05:00
# ifndef pIMultiLanguage
DWORD dw = 0 ;
2010-11-11 07:30:39 -05:00
UINT n = len ;
2009-02-09 06:11:57 -05:00
HRESULT hr = pIMultiLanguage - > lpVtbl - > ConvertStringToUnicode ( pIMultiLanguage ,
2015-09-21 10:40:57 -04:00
& dw , cp , pm , & n , NULL , & size ) ;
2008-10-12 05:06:45 -04:00
if ( FAILED ( hr ) ) {
2015-09-21 10:40:57 -04:00
ole_raise ( hr , eWIN32OLERuntimeError , " fail to convert CP%d to Unicode " , cp ) ;
2008-10-12 05:06:45 -04:00
}
pw = SysAllocStringLen ( NULL , size ) ;
2015-09-21 10:40:57 -04:00
n = len ;
2008-10-14 08:44:37 -04:00
hr = pIMultiLanguage - > lpVtbl - > ConvertStringToUnicode ( pIMultiLanguage ,
2015-09-21 10:40:57 -04:00
& dw , cp , pm , & n , pw , & size ) ;
2008-10-12 05:06:45 -04:00
if ( FAILED ( hr ) ) {
2015-09-21 10:40:57 -04:00
ole_raise ( hr , eWIN32OLERuntimeError , " fail to convert CP%d to Unicode " , cp ) ;
2008-10-12 05:06:45 -04:00
}
return pw ;
2014-12-26 01:09:11 -05:00
# endif
2008-10-12 05:06:45 -04:00
}
2015-09-21 10:40:57 -04:00
size = MultiByteToWideChar ( cp , 0 , pm , len , NULL , 0 ) ;
pw = SysAllocStringLen ( NULL , size ) ;
pw [ size - 1 ] = 0 ;
MultiByteToWideChar ( cp , 0 , pm , len , pw , size ) ;
2002-06-01 08:34:30 -04:00
return pw ;
}
2013-08-23 04:17:59 -04:00
static char *
ole_alloc_vstr ( UINT size , void * arg )
{
VALUE str = rb_enc_str_new ( NULL , size , cWIN32OLE_enc ) ;
* ( VALUE * ) arg = str ;
return RSTRING_PTR ( str ) ;
}
2014-08-06 08:00:09 -04:00
VALUE
2006-04-30 09:11:12 -04:00
ole_wc2vstr ( LPWSTR pw , BOOL isfree )
2002-06-01 08:34:30 -04:00
{
2013-08-23 04:17:59 -04:00
VALUE vstr ;
ole_wc2mb_alloc ( pw , ole_alloc_vstr , & vstr ) ;
rb_str_set_len ( vstr , ( long ) strlen ( RSTRING_PTR ( vstr ) ) ) ;
2002-06-01 08:34:30 -04:00
if ( isfree )
SysFreeString ( pw ) ;
return vstr ;
}
static VALUE
2014-04-19 20:12:15 -04:00
ole_ary_m_entry ( VALUE val , LONG * pid )
2002-06-01 08:34:30 -04:00
{
VALUE obj = Qnil ;
int i = 0 ;
obj = val ;
2014-08-02 21:56:01 -04:00
while ( RB_TYPE_P ( obj , T_ARRAY ) ) {
2002-06-01 08:34:30 -04:00
obj = rb_ary_entry ( obj , pid [ i ] ) ;
i + + ;
}
return obj ;
}
2014-08-13 08:46:23 -04:00
static VALUE
is_all_index_under ( LONG * pid , long * pub , long dim )
{
long i = 0 ;
for ( i = 0 ; i < dim ; i + + ) {
if ( pid [ i ] > pub [ i ] ) {
return Qfalse ;
}
}
return Qtrue ;
}
void
ole_val2variant_ex ( VALUE val , VARIANT * var , VARTYPE vt )
{
if ( val = = Qnil ) {
if ( vt = = VT_VARIANT ) {
ole_val2variant2 ( val , var ) ;
} else {
V_VT ( var ) = ( vt & ~ VT_BYREF ) ;
if ( V_VT ( var ) = = VT_DISPATCH ) {
V_DISPATCH ( var ) = NULL ;
} else if ( V_VT ( var ) = = VT_UNKNOWN ) {
V_UNKNOWN ( var ) = NULL ;
}
}
return ;
}
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
switch ( vt & ~ VT_BYREF ) {
case VT_I8 :
V_VT ( var ) = VT_I8 ;
V_I8 ( var ) = NUM2I8 ( val ) ;
break ;
case VT_UI8 :
V_VT ( var ) = VT_UI8 ;
V_UI8 ( var ) = NUM2UI8 ( val ) ;
break ;
default :
ole_val2variant2 ( val , var ) ;
break ;
}
# else /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
ole_val2variant2 ( val , var ) ;
# endif
}
VOID *
val2variant_ptr ( VALUE val , VARIANT * var , VARTYPE vt )
{
VOID * p = NULL ;
HRESULT hr = S_OK ;
ole_val2variant_ex ( val , var , vt ) ;
if ( ( vt & ~ VT_BYREF ) = = VT_VARIANT ) {
p = var ;
} else {
if ( ( vt & ~ VT_BYREF ) ! = V_VT ( var ) ) {
hr = VariantChangeTypeEx ( var , var ,
cWIN32OLE_lcid , 0 , ( VARTYPE ) ( vt & ~ VT_BYREF ) ) ;
if ( FAILED ( hr ) ) {
ole_raise ( hr , rb_eRuntimeError , " failed to change type " ) ;
}
}
p = get_ptr_of_variant ( var ) ;
}
if ( p = = NULL ) {
rb_raise ( rb_eRuntimeError , " failed to get pointer of variant " ) ;
}
return p ;
}
2008-07-23 18:01:36 -04:00
static void *
get_ptr_of_variant ( VARIANT * pvar )
2006-03-12 03:09:48 -05:00
{
switch ( V_VT ( pvar ) ) {
case VT_UI1 :
return & V_UI1 ( pvar ) ;
break ;
case VT_I2 :
return & V_I2 ( pvar ) ;
break ;
2007-03-02 07:35:02 -05:00
case VT_UI2 :
return & V_UI2 ( pvar ) ;
break ;
2006-03-12 03:09:48 -05:00
case VT_I4 :
return & V_I4 ( pvar ) ;
break ;
case VT_UI4 :
return & V_UI4 ( pvar ) ;
break ;
case VT_R4 :
return & V_R4 ( pvar ) ;
break ;
case VT_R8 :
return & V_R8 ( pvar ) ;
break ;
2007-03-02 07:35:02 -05:00
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
case VT_I8 :
return & V_I8 ( pvar ) ;
break ;
case VT_UI8 :
return & V_UI8 ( pvar ) ;
break ;
# endif
case VT_INT :
return & V_INT ( pvar ) ;
break ;
case VT_UINT :
return & V_UINT ( pvar ) ;
break ;
2006-03-12 03:09:48 -05:00
case VT_CY :
return & V_CY ( pvar ) ;
break ;
case VT_DATE :
return & V_DATE ( pvar ) ;
break ;
case VT_BSTR :
2007-03-02 07:35:02 -05:00
return V_BSTR ( pvar ) ;
2006-03-12 03:09:48 -05:00
break ;
case VT_DISPATCH :
2007-03-02 07:35:02 -05:00
return V_DISPATCH ( pvar ) ;
2006-03-12 03:09:48 -05:00
break ;
case VT_ERROR :
return & V_ERROR ( pvar ) ;
break ;
case VT_BOOL :
return & V_BOOL ( pvar ) ;
break ;
case VT_UNKNOWN :
2007-03-02 07:35:02 -05:00
return V_UNKNOWN ( pvar ) ;
2006-03-12 03:09:48 -05:00
break ;
case VT_ARRAY :
return & V_ARRAY ( pvar ) ;
break ;
default :
return NULL ;
break ;
}
}
static void
2014-04-19 20:12:15 -04:00
ole_set_safe_array ( long n , SAFEARRAY * psa , LONG * pid , long * pub , VALUE val , long dim , VARTYPE vt )
2006-03-12 03:09:48 -05:00
{
VALUE val1 ;
2007-02-08 08:48:16 -05:00
HRESULT hr = S_OK ;
2006-03-12 03:09:48 -05:00
VARIANT var ;
VOID * p = NULL ;
2008-01-18 19:29:31 -05:00
long i = n ;
while ( i > = 0 ) {
2006-03-12 03:09:48 -05:00
val1 = ole_ary_m_entry ( val , pid ) ;
2008-01-18 19:29:31 -05:00
VariantInit ( & var ) ;
2007-02-23 17:39:25 -05:00
p = val2variant_ptr ( val1 , & var , vt ) ;
2007-02-08 08:48:16 -05:00
if ( is_all_index_under ( pid , pub , dim ) = = Qtrue ) {
2008-01-18 19:29:31 -05:00
if ( ( V_VT ( & var ) = = VT_DISPATCH & & V_DISPATCH ( & var ) = = NULL ) | |
( V_VT ( & var ) = = VT_UNKNOWN & & V_UNKNOWN ( & var ) = = NULL ) ) {
rb_raise ( eWIN32OLERuntimeError , " element of array does not have IDispatch or IUnknown Interface " ) ;
2007-03-02 07:35:02 -05:00
}
2007-02-08 08:48:16 -05:00
hr = SafeArrayPutElement ( psa , pid , p ) ;
}
2006-03-12 03:09:48 -05:00
if ( FAILED ( hr ) ) {
ole_raise ( hr , rb_eRuntimeError , " failed to SafeArrayPutElement " ) ;
}
2008-01-18 19:29:31 -05:00
pid [ i ] + = 1 ;
if ( pid [ i ] > pub [ i ] ) {
pid [ i ] = 0 ;
i - = 1 ;
} else {
i = dim - 1 ;
}
2007-02-03 00:41:03 -05:00
}
}
static long
dimension ( VALUE val ) {
long dim = 0 ;
long dim1 = 0 ;
long len = 0 ;
long i = 0 ;
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( val , T_ARRAY ) ) {
2007-02-03 00:41:03 -05:00
len = RARRAY_LEN ( val ) ;
for ( i = 0 ; i < len ; i + + ) {
dim1 = dimension ( rb_ary_entry ( val , i ) ) ;
if ( dim < dim1 ) {
dim = dim1 ;
}
}
dim + = 1 ;
}
return dim ;
}
2010-04-22 04:04:13 -04:00
static long
2007-02-03 00:41:03 -05:00
ary_len_of_dim ( VALUE ary , long dim ) {
long ary_len = 0 ;
long ary_len1 = 0 ;
long len = 0 ;
long i = 0 ;
VALUE val ;
if ( dim = = 0 ) {
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( ary , T_ARRAY ) ) {
2007-02-03 00:41:03 -05:00
ary_len = RARRAY_LEN ( ary ) ;
}
} else {
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( ary , T_ARRAY ) ) {
2007-02-03 00:41:03 -05:00
len = RARRAY_LEN ( ary ) ;
for ( i = 0 ; i < len ; i + + ) {
val = rb_ary_entry ( ary , i ) ;
ary_len1 = ary_len_of_dim ( val , dim - 1 ) ;
if ( ary_len < ary_len1 ) {
ary_len = ary_len1 ;
}
}
}
}
return ary_len ;
}
2014-08-13 08:46:23 -04:00
HRESULT
2007-02-23 17:39:25 -05:00
ole_val_ary2variant_ary ( VALUE val , VARIANT * var , VARTYPE vt )
2007-02-03 00:41:03 -05:00
{
long dim = 0 ;
int i = 0 ;
HRESULT hr = S_OK ;
SAFEARRAYBOUND * psab = NULL ;
SAFEARRAY * psa = NULL ;
2014-04-19 20:12:15 -04:00
long * pub ;
LONG * pid ;
2007-02-03 00:41:03 -05:00
Check_Type ( val , T_ARRAY ) ;
dim = dimension ( val ) ;
psab = ALLOC_N ( SAFEARRAYBOUND , dim ) ;
pub = ALLOC_N ( long , dim ) ;
2014-04-19 20:12:15 -04:00
pid = ALLOC_N ( LONG , dim ) ;
2007-02-03 00:41:03 -05:00
if ( ! psab | | ! pub | | ! pid ) {
if ( pub ) free ( pub ) ;
if ( psab ) free ( psab ) ;
if ( pid ) free ( pid ) ;
rb_raise ( rb_eRuntimeError , " memory allocation error " ) ;
}
for ( i = 0 ; i < dim ; i + + ) {
psab [ i ] . cElements = ary_len_of_dim ( val , i ) ;
psab [ i ] . lLbound = 0 ;
2007-02-08 08:48:16 -05:00
pub [ i ] = psab [ i ] . cElements - 1 ;
2007-02-03 00:41:03 -05:00
pid [ i ] = 0 ;
}
/* Create and fill VARIANT array */
2007-02-23 17:39:25 -05:00
if ( ( vt & ~ VT_BYREF ) = = VT_ARRAY ) {
vt = ( vt | VT_VARIANT ) ;
2007-02-03 00:41:03 -05:00
}
2008-04-21 20:58:51 -04:00
psa = SafeArrayCreate ( ( VARTYPE ) ( vt & VT_TYPEMASK ) , dim , psab ) ;
2007-02-03 00:41:03 -05:00
if ( psa = = NULL )
hr = E_OUTOFMEMORY ;
else
hr = SafeArrayLock ( psa ) ;
if ( SUCCEEDED ( hr ) ) {
2008-04-21 20:58:51 -04:00
ole_set_safe_array ( dim - 1 , psa , pid , pub , val , dim , ( VARTYPE ) ( vt & VT_TYPEMASK ) ) ;
2007-02-03 00:41:03 -05:00
hr = SafeArrayUnlock ( psa ) ;
}
if ( pub ) free ( pub ) ;
if ( psab ) free ( psab ) ;
if ( pid ) free ( pid ) ;
if ( SUCCEEDED ( hr ) ) {
2007-02-23 17:39:25 -05:00
V_VT ( var ) = vt ;
2007-02-03 00:41:03 -05:00
V_ARRAY ( var ) = psa ;
}
else {
if ( psa ! = NULL )
SafeArrayDestroy ( psa ) ;
2006-03-12 03:09:48 -05:00
}
2007-02-03 00:41:03 -05:00
return hr ;
2006-03-12 03:09:48 -05:00
}
2014-08-13 08:46:23 -04:00
void
2006-04-30 09:11:12 -04:00
ole_val2variant ( VALUE val , VARIANT * var )
2002-06-01 08:34:30 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
if ( rb_obj_is_kind_of ( val , cWIN32OLE ) ) {
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( val ) ;
2004-02-15 01:53:15 -05:00
OLE_ADDREF ( pole - > pDispatch ) ;
2002-06-01 08:34:30 -04:00
V_VT ( var ) = VT_DISPATCH ;
V_DISPATCH ( var ) = pole - > pDispatch ;
return ;
}
2006-03-12 03:09:48 -05:00
if ( rb_obj_is_kind_of ( val , cWIN32OLE_VARIANT ) ) {
2014-10-25 18:46:15 -04:00
ole_variant2variant ( val , var ) ;
2006-03-12 03:09:48 -05:00
return ;
}
2014-07-24 09:51:22 -04:00
if ( rb_obj_is_kind_of ( val , cWIN32OLE_RECORD ) ) {
ole_rec2variant ( val , var ) ;
return ;
}
2002-06-01 08:34:30 -04:00
if ( rb_obj_is_kind_of ( val , rb_cTime ) ) {
V_VT ( var ) = VT_DATE ;
2009-07-21 03:27:08 -04:00
V_DATE ( var ) = rbtime2vtdate ( val ) ;
2002-06-01 08:34:30 -04:00
return ;
}
switch ( TYPE ( val ) ) {
case T_ARRAY :
2007-02-03 00:41:03 -05:00
ole_val_ary2variant_ary ( val , var , VT_VARIANT | VT_ARRAY ) ;
2002-06-01 08:34:30 -04:00
break ;
case T_STRING :
V_VT ( var ) = VT_BSTR ;
2008-06-27 19:43:57 -04:00
V_BSTR ( var ) = ole_vstr2wc ( val ) ;
2002-06-01 08:34:30 -04:00
break ;
case T_FIXNUM :
V_VT ( var ) = VT_I4 ;
V_I4 ( var ) = NUM2INT ( val ) ;
break ;
case T_BIGNUM :
2004-02-15 01:53:15 -05:00
V_VT ( var ) = VT_R8 ;
2002-06-01 08:34:30 -04:00
V_R8 ( var ) = rb_big2dbl ( val ) ;
2004-02-15 01:53:15 -05:00
break ;
2002-06-01 08:34:30 -04:00
case T_FLOAT :
V_VT ( var ) = VT_R8 ;
V_R8 ( var ) = NUM2DBL ( val ) ;
break ;
case T_TRUE :
V_VT ( var ) = VT_BOOL ;
V_BOOL ( var ) = VARIANT_TRUE ;
break ;
case T_FALSE :
V_VT ( var ) = VT_BOOL ;
V_BOOL ( var ) = VARIANT_FALSE ;
break ;
case T_NIL :
2005-04-15 09:05:01 -04:00
if ( g_nil_to = = VT_ERROR ) {
V_VT ( var ) = VT_ERROR ;
V_ERROR ( var ) = DISP_E_PARAMNOTFOUND ;
} else {
V_VT ( var ) = VT_EMPTY ;
}
2002-06-01 08:34:30 -04:00
break ;
default :
2004-02-15 01:53:15 -05:00
V_VT ( var ) = VT_DISPATCH ;
V_DISPATCH ( var ) = val2dispatch ( val ) ;
2002-06-01 08:34:30 -04:00
break ;
}
}
2014-08-13 08:46:23 -04:00
void
2006-04-30 09:11:12 -04:00
ole_val2variant2 ( VALUE val , VARIANT * var )
2005-04-15 09:05:01 -04:00
{
g_nil_to = VT_EMPTY ;
ole_val2variant ( val , var ) ;
g_nil_to = VT_ERROR ;
}
2014-08-11 07:50:17 -04:00
VALUE
2010-04-22 04:04:13 -04:00
make_inspect ( const char * class_name , VALUE detail )
2006-04-01 01:23:07 -05:00
{
VALUE str ;
str = rb_str_new2 ( " #< " ) ;
rb_str_cat2 ( str , class_name ) ;
rb_str_cat2 ( str , " : " ) ;
rb_str_concat ( str , detail ) ;
rb_str_cat2 ( str , " > " ) ;
return str ;
}
2014-08-06 08:00:09 -04:00
VALUE
2010-04-22 04:04:13 -04:00
default_inspect ( VALUE self , const char * class_name )
2006-04-01 01:23:07 -05:00
{
VALUE detail = rb_funcall ( self , rb_intern ( " to_s " ) , 0 ) ;
return make_inspect ( class_name , detail ) ;
}
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
ole_set_member ( VALUE self , IDispatch * dispatch )
2002-06-01 08:34:30 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
if ( pole - > pDispatch ) {
OLE_RELEASE ( pole - > pDispatch ) ;
pole - > pDispatch = NULL ;
}
pole - > pDispatch = dispatch ;
return self ;
}
2006-04-01 01:23:07 -05:00
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_allocate ( VALUE klass )
2002-06-01 08:34:30 -04:00
{
struct oledata * pole ;
VALUE obj ;
ole_initialize ( ) ;
2014-12-01 06:03:13 -05:00
obj = TypedData_Make_Struct ( klass , struct oledata , & ole_datatype , pole ) ;
2002-06-01 08:34:30 -04:00
pole - > pDispatch = NULL ;
return obj ;
}
static VALUE
2006-04-30 09:11:12 -04:00
create_win32ole_object ( VALUE klass , IDispatch * pDispatch , int argc , VALUE * argv )
2002-06-01 08:34:30 -04:00
{
VALUE obj = fole_s_allocate ( klass ) ;
ole_set_member ( obj , pDispatch ) ;
return obj ;
}
2007-02-08 08:48:16 -05:00
static VALUE
2014-04-19 20:12:15 -04:00
ary_new_dim ( VALUE myary , LONG * pid , LONG * plb , LONG dim ) {
2007-02-03 00:41:03 -05:00
long i ;
VALUE obj = Qnil ;
VALUE pobj = Qnil ;
long * ids = ALLOC_N ( long , dim ) ;
if ( ! ids ) {
rb_raise ( rb_eRuntimeError , " memory allocation error " ) ;
}
for ( i = 0 ; i < dim ; i + + ) {
2007-02-08 08:48:16 -05:00
ids [ i ] = pid [ i ] - plb [ i ] ;
2007-02-03 00:41:03 -05:00
}
obj = myary ;
pobj = myary ;
for ( i = 0 ; i < dim - 1 ; i + + ) {
obj = rb_ary_entry ( pobj , ids [ i ] ) ;
if ( obj = = Qnil ) {
rb_ary_store ( pobj , ids [ i ] , rb_ary_new ( ) ) ;
}
obj = rb_ary_entry ( pobj , ids [ i ] ) ;
pobj = obj ;
}
if ( ids ) free ( ids ) ;
2007-02-08 08:48:16 -05:00
return obj ;
}
static void
2014-04-19 20:12:15 -04:00
ary_store_dim ( VALUE myary , LONG * pid , LONG * plb , LONG dim , VALUE val ) {
2007-02-08 08:48:16 -05:00
long id = pid [ dim - 1 ] - plb [ dim - 1 ] ;
VALUE obj = ary_new_dim ( myary , pid , plb , dim ) ;
rb_ary_store ( obj , id , val ) ;
2007-02-03 00:41:03 -05:00
}
2014-08-11 07:50:17 -04:00
VALUE
2006-04-30 09:11:12 -04:00
ole_variant2val ( VARIANT * pvar )
2002-06-01 08:34:30 -04:00
{
VALUE obj = Qnil ;
2014-07-16 10:05:52 -04:00
VARTYPE vt = V_VT ( pvar ) ;
2002-06-01 08:34:30 -04:00
HRESULT hr ;
2014-07-16 10:05:52 -04:00
while ( vt = = ( VT_BYREF | VT_VARIANT ) ) {
2002-06-01 08:34:30 -04:00
pvar = V_VARIANTREF ( pvar ) ;
2014-07-16 10:05:52 -04:00
vt = V_VT ( pvar ) ;
}
2002-06-01 08:34:30 -04:00
if ( V_ISARRAY ( pvar ) ) {
2014-07-16 10:05:52 -04:00
VARTYPE vt_base = vt & VT_TYPEMASK ;
2002-06-01 08:34:30 -04:00
SAFEARRAY * psa = V_ISBYREF ( pvar ) ? * V_ARRAYREF ( pvar ) : V_ARRAY ( pvar ) ;
2007-02-20 07:25:40 -05:00
UINT i = 0 ;
2014-04-19 20:12:15 -04:00
LONG * pid , * plb , * pub ;
2002-06-01 08:34:30 -04:00
VARIANT variant ;
VALUE val ;
2007-02-08 08:48:16 -05:00
UINT dim = 0 ;
if ( ! psa ) {
return obj ;
}
dim = SafeArrayGetDim ( psa ) ;
2014-04-19 20:12:15 -04:00
pid = ALLOC_N ( LONG , dim ) ;
plb = ALLOC_N ( LONG , dim ) ;
pub = ALLOC_N ( LONG , dim ) ;
2002-06-01 08:34:30 -04:00
2007-02-03 00:41:03 -05:00
if ( ! pid | | ! plb | | ! pub ) {
if ( pid ) free ( pid ) ;
if ( plb ) free ( plb ) ;
if ( pub ) free ( pub ) ;
2004-03-29 02:54:38 -05:00
rb_raise ( rb_eRuntimeError , " memory allocation error " ) ;
2002-06-01 08:34:30 -04:00
}
for ( i = 0 ; i < dim ; + + i ) {
2007-02-03 00:41:03 -05:00
SafeArrayGetLBound ( psa , i + 1 , & plb [ i ] ) ;
SafeArrayGetLBound ( psa , i + 1 , & pid [ i ] ) ;
SafeArrayGetUBound ( psa , i + 1 , & pub [ i ] ) ;
2002-06-01 08:34:30 -04:00
}
hr = SafeArrayLock ( psa ) ;
if ( SUCCEEDED ( hr ) ) {
2007-02-03 00:41:03 -05:00
obj = rb_ary_new ( ) ;
2007-02-20 07:25:40 -05:00
i = 0 ;
2014-07-16 10:05:52 -04:00
VariantInit ( & variant ) ;
V_VT ( & variant ) = vt_base | VT_BYREF ;
if ( vt_base = = VT_RECORD ) {
hr = SafeArrayGetRecordInfo ( psa , & V_RECORDINFO ( & variant ) ) ;
if ( SUCCEEDED ( hr ) ) {
V_VT ( & variant ) = VT_RECORD ;
}
}
2007-02-20 07:25:40 -05:00
while ( i < dim ) {
2007-02-08 08:48:16 -05:00
ary_new_dim ( obj , pid , plb , dim ) ;
2014-07-16 10:05:52 -04:00
if ( vt_base = = VT_RECORD )
hr = SafeArrayPtrOfIndex ( psa , pid , & V_RECORD ( & variant ) ) ;
else
hr = SafeArrayPtrOfIndex ( psa , pid , & V_BYREF ( & variant ) ) ;
2007-02-08 08:48:16 -05:00
if ( SUCCEEDED ( hr ) ) {
val = ole_variant2val ( & variant ) ;
ary_store_dim ( obj , pid , plb , dim , val ) ;
}
2007-02-20 07:25:40 -05:00
for ( i = 0 ; i < dim ; + + i ) {
2007-02-03 00:41:03 -05:00
if ( + + pid [ i ] < = pub [ i ] )
2002-06-01 08:34:30 -04:00
break ;
2007-02-03 00:41:03 -05:00
pid [ i ] = plb [ i ] ;
2002-06-01 08:34:30 -04:00
}
}
SafeArrayUnlock ( psa ) ;
}
2007-02-03 00:41:03 -05:00
if ( pid ) free ( pid ) ;
if ( plb ) free ( plb ) ;
if ( pub ) free ( pub ) ;
return obj ;
2002-06-01 08:34:30 -04:00
}
switch ( V_VT ( pvar ) & ~ VT_BYREF ) {
case VT_EMPTY :
break ;
case VT_NULL :
break ;
2007-03-02 07:35:02 -05:00
case VT_I1 :
2010-04-22 04:04:13 -04:00
if ( V_ISBYREF ( pvar ) )
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) * V_I1REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) V_I1 ( pvar ) ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UI1 :
2010-04-22 04:04:13 -04:00
if ( V_ISBYREF ( pvar ) )
2002-06-01 08:34:30 -04:00
obj = INT2NUM ( ( long ) * V_UI1REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2002-06-01 08:34:30 -04:00
obj = INT2NUM ( ( long ) V_UI1 ( pvar ) ) ;
break ;
case VT_I2 :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_I2REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2002-06-01 08:34:30 -04:00
obj = INT2NUM ( ( long ) V_I2 ( pvar ) ) ;
break ;
2007-03-02 07:35:02 -05:00
case VT_UI2 :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_UI2REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) V_UI2 ( pvar ) ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_I4 :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_I4REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2002-06-01 08:34:30 -04:00
obj = INT2NUM ( ( long ) V_I4 ( pvar ) ) ;
break ;
2007-03-02 07:35:02 -05:00
case VT_UI4 :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_UI4REF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) V_UI4 ( pvar ) ) ;
break ;
case VT_INT :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_INTREF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) V_INT ( pvar ) ) ;
break ;
case VT_UINT :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( ( long ) * V_UINTREF ( pvar ) ) ;
2010-04-22 04:04:13 -04:00
else
2007-03-02 07:35:02 -05:00
obj = INT2NUM ( ( long ) V_UINT ( pvar ) ) ;
break ;
2007-02-14 08:57:59 -05:00
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
2007-02-12 00:00:41 -05:00
case VT_I8 :
2007-03-02 07:35:02 -05:00
if ( V_ISBYREF ( pvar ) )
2013-01-11 17:59:51 -05:00
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
# ifdef V_I8REF
2007-03-02 07:35:02 -05:00
obj = I8_2_NUM ( * V_I8REF ( pvar ) ) ;
2013-01-11 17:59:51 -05:00
# endif
2010-04-22 04:04:13 -04:00
# else
2007-03-02 07:35:02 -05:00
obj = Qnil ;
# endif
else
obj = I8_2_NUM ( V_I8 ( pvar ) ) ;
2007-02-12 00:00:41 -05:00
break ;
case VT_UI8 :
2007-03-02 07:35:02 -05:00
if ( V_ISBYREF ( pvar ) )
2013-01-11 17:59:51 -05:00
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
# ifdef V_UI8REF
2007-03-02 07:35:02 -05:00
obj = UI8_2_NUM ( * V_UI8REF ( pvar ) ) ;
2013-01-11 17:59:51 -05:00
# endif
2007-02-12 00:00:41 -05:00
# else
2007-03-02 07:35:02 -05:00
obj = Qnil ;
2007-02-12 00:00:41 -05:00
# endif
2007-03-02 07:35:02 -05:00
else
obj = UI8_2_NUM ( V_UI8 ( pvar ) ) ;
2007-02-12 00:00:41 -05:00
break ;
2007-02-14 08:57:59 -05:00
# endif /* (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) */
2007-03-02 07:35:02 -05:00
2002-06-01 08:34:30 -04:00
case VT_R4 :
if ( V_ISBYREF ( pvar ) )
obj = rb_float_new ( * V_R4REF ( pvar ) ) ;
else
obj = rb_float_new ( V_R4 ( pvar ) ) ;
break ;
case VT_R8 :
if ( V_ISBYREF ( pvar ) )
obj = rb_float_new ( * V_R8REF ( pvar ) ) ;
else
obj = rb_float_new ( V_R8 ( pvar ) ) ;
break ;
case VT_BSTR :
{
2015-12-26 19:48:20 -05:00
if ( V_ISBYREF ( pvar ) ) {
obj = ( SysStringLen ( * V_BSTRREF ( pvar ) ) = = 0 )
? rb_str_new2 ( " " )
: ole_wc2vstr ( * V_BSTRREF ( pvar ) , FALSE ) ;
}
else {
obj = ( SysStringLen ( V_BSTR ( pvar ) ) = = 0 )
? rb_str_new2 ( " " )
: ole_wc2vstr ( V_BSTR ( pvar ) , FALSE ) ;
}
2002-06-01 08:34:30 -04:00
break ;
}
case VT_ERROR :
if ( V_ISBYREF ( pvar ) )
obj = INT2NUM ( * V_ERRORREF ( pvar ) ) ;
else
obj = INT2NUM ( V_ERROR ( pvar ) ) ;
break ;
case VT_BOOL :
if ( V_ISBYREF ( pvar ) )
obj = ( * V_BOOLREF ( pvar ) ? Qtrue : Qfalse ) ;
else
obj = ( V_BOOL ( pvar ) ? Qtrue : Qfalse ) ;
break ;
case VT_DISPATCH :
{
IDispatch * pDispatch ;
if ( V_ISBYREF ( pvar ) )
pDispatch = * V_DISPATCHREF ( pvar ) ;
else
pDispatch = V_DISPATCH ( pvar ) ;
if ( pDispatch ! = NULL ) {
2004-02-15 01:53:15 -05:00
OLE_ADDREF ( pDispatch ) ;
2002-06-01 08:34:30 -04:00
obj = create_win32ole_object ( cWIN32OLE , pDispatch , 0 , 0 ) ;
}
break ;
}
case VT_UNKNOWN :
{
/* get IDispatch interface from IUnknown interface */
IUnknown * punk ;
IDispatch * pDispatch ;
2008-07-23 18:01:36 -04:00
void * p ;
2002-06-01 08:34:30 -04:00
HRESULT hr ;
if ( V_ISBYREF ( pvar ) )
punk = * V_UNKNOWNREF ( pvar ) ;
else
punk = V_UNKNOWN ( pvar ) ;
if ( punk ! = NULL ) {
2008-07-23 18:01:36 -04:00
hr = punk - > lpVtbl - > QueryInterface ( punk , & IID_IDispatch , & p ) ;
2002-06-01 08:34:30 -04:00
if ( SUCCEEDED ( hr ) ) {
2008-07-23 18:01:36 -04:00
pDispatch = p ;
2002-06-01 08:34:30 -04:00
obj = create_win32ole_object ( cWIN32OLE , pDispatch , 0 , 0 ) ;
}
}
break ;
}
case VT_DATE :
{
DATE date ;
if ( V_ISBYREF ( pvar ) )
date = * V_DATEREF ( pvar ) ;
else
date = V_DATE ( pvar ) ;
2009-07-21 03:27:08 -04:00
obj = vtdate2rbtime ( date ) ;
2002-06-01 08:34:30 -04:00
break ;
}
2014-07-11 07:50:51 -04:00
case VT_RECORD :
{
IRecordInfo * pri = V_RECORDINFO ( pvar ) ;
void * prec = V_RECORD ( pvar ) ;
2014-08-13 11:28:26 -04:00
obj = create_win32ole_record ( pri , prec ) ;
2014-07-11 07:50:51 -04:00
break ;
}
2002-06-01 08:34:30 -04:00
case VT_CY :
default :
{
HRESULT hr ;
VARIANT variant ;
VariantInit ( & variant ) ;
2010-04-22 04:04:13 -04:00
hr = VariantChangeTypeEx ( & variant , pvar ,
2007-01-29 07:41:50 -05:00
cWIN32OLE_lcid , 0 , VT_BSTR ) ;
2002-06-01 08:34:30 -04:00
if ( SUCCEEDED ( hr ) & & V_VT ( & variant ) = = VT_BSTR ) {
2008-01-28 05:42:53 -05:00
obj = ole_wc2vstr ( V_BSTR ( & variant ) , FALSE ) ;
2002-06-01 08:34:30 -04:00
}
VariantClear ( & variant ) ;
break ;
}
}
return obj ;
}
2014-08-06 08:00:09 -04:00
LONG
2007-02-03 00:41:03 -05:00
reg_open_key ( HKEY hkey , const char * name , HKEY * phkey )
2002-06-01 08:34:30 -04:00
{
return RegOpenKeyEx ( hkey , name , 0 , KEY_READ , phkey ) ;
}
2014-08-06 08:00:09 -04:00
LONG
2007-02-03 00:41:03 -05:00
reg_open_vkey ( HKEY hkey , VALUE key , HKEY * phkey )
2002-06-01 08:34:30 -04:00
{
return reg_open_key ( hkey , StringValuePtr ( key ) , phkey ) ;
}
2014-08-06 08:00:09 -04:00
VALUE
2006-04-30 09:11:12 -04:00
reg_enum_key ( HKEY hkey , DWORD i )
2002-06-01 08:34:30 -04:00
{
2007-08-25 17:57:46 -04:00
char buf [ BUFSIZ + 1 ] ;
2002-06-12 08:23:10 -04:00
DWORD size_buf = sizeof ( buf ) ;
2002-06-01 08:34:30 -04:00
FILETIME ft ;
LONG err = RegEnumKeyEx ( hkey , i , buf , & size_buf ,
NULL , NULL , NULL , & ft ) ;
if ( err = = ERROR_SUCCESS ) {
2007-08-25 17:57:46 -04:00
buf [ BUFSIZ ] = ' \0 ' ;
2002-06-01 08:34:30 -04:00
return rb_str_new2 ( buf ) ;
}
return Qnil ;
}
2014-08-06 08:00:09 -04:00
VALUE
2006-04-30 09:11:12 -04:00
reg_get_val ( HKEY hkey , const char * subkey )
2002-06-01 08:34:30 -04:00
{
2007-08-23 07:14:03 -04:00
char * pbuf ;
DWORD dwtype = 0 ;
2010-11-11 07:30:39 -05:00
DWORD size = 0 ;
2007-08-23 07:14:03 -04:00
VALUE val = Qnil ;
2010-04-22 04:04:13 -04:00
LONG err = RegQueryValueEx ( hkey , subkey , NULL , & dwtype , NULL , & size ) ;
2007-08-23 07:14:03 -04:00
2002-06-01 08:34:30 -04:00
if ( err = = ERROR_SUCCESS ) {
2007-08-23 07:14:03 -04:00
pbuf = ALLOC_N ( char , size + 1 ) ;
2010-11-11 07:30:39 -05:00
err = RegQueryValueEx ( hkey , subkey , NULL , & dwtype , ( BYTE * ) pbuf , & size ) ;
2007-08-23 07:14:03 -04:00
if ( err = = ERROR_SUCCESS ) {
pbuf [ size ] = ' \0 ' ;
2010-10-14 07:56:10 -04:00
if ( dwtype = = REG_EXPAND_SZ ) {
2010-11-11 07:30:39 -05:00
char * pbuf2 = ( char * ) pbuf ;
DWORD len = ExpandEnvironmentStrings ( pbuf2 , NULL , 0 ) ;
pbuf = ALLOC_N ( char , len + 1 ) ;
ExpandEnvironmentStrings ( pbuf2 , pbuf , len + 1 ) ;
free ( pbuf2 ) ;
2010-10-14 07:56:10 -04:00
}
2010-11-11 07:30:39 -05:00
val = rb_str_new2 ( ( char * ) pbuf ) ;
2007-08-23 07:14:03 -04:00
}
free ( pbuf ) ;
2002-06-01 08:34:30 -04:00
}
2007-08-23 07:14:03 -04:00
return val ;
}
2014-08-06 08:00:09 -04:00
VALUE
2007-08-23 07:14:03 -04:00
reg_get_val2 ( HKEY hkey , const char * subkey )
{
HKEY hsubkey ;
LONG err ;
VALUE val = Qnil ;
err = RegOpenKeyEx ( hkey , subkey , 0 , KEY_READ , & hsubkey ) ;
if ( err = = ERROR_SUCCESS ) {
val = reg_get_val ( hsubkey , NULL ) ;
RegCloseKey ( hsubkey ) ;
}
if ( val = = Qnil ) {
val = reg_get_val ( hkey , subkey ) ;
}
return val ;
2002-06-01 08:34:30 -04:00
}
static void
2006-04-30 09:11:12 -04:00
ole_const_load ( ITypeLib * pTypeLib , VALUE klass , VALUE self )
2002-06-01 08:34:30 -04:00
{
unsigned int count ;
unsigned int index ;
int iVar ;
ITypeInfo * pTypeInfo ;
TYPEATTR * pTypeAttr ;
VARDESC * pVarDesc ;
HRESULT hr ;
unsigned int len ;
BSTR bstr ;
char * pName = NULL ;
VALUE val ;
VALUE constant ;
ID id ;
constant = rb_hash_new ( ) ;
count = pTypeLib - > lpVtbl - > GetTypeInfoCount ( pTypeLib ) ;
for ( index = 0 ; index < count ; index + + ) {
hr = pTypeLib - > lpVtbl - > GetTypeInfo ( pTypeLib , index , & pTypeInfo ) ;
if ( FAILED ( hr ) )
continue ;
hr = OLE_GET_TYPEATTR ( pTypeInfo , & pTypeAttr ) ;
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pTypeInfo ) ;
continue ;
}
for ( iVar = 0 ; iVar < pTypeAttr - > cVars ; iVar + + ) {
hr = pTypeInfo - > lpVtbl - > GetVarDesc ( pTypeInfo , iVar , & pVarDesc ) ;
if ( FAILED ( hr ) )
continue ;
if ( pVarDesc - > varkind = = VAR_CONST & &
! ( pVarDesc - > wVarFlags & ( VARFLAG_FHIDDEN |
VARFLAG_FRESTRICTED |
VARFLAG_FNONBROWSABLE ) ) ) {
hr = pTypeInfo - > lpVtbl - > GetNames ( pTypeInfo , pVarDesc - > memid , & bstr ,
1 , & len ) ;
if ( FAILED ( hr ) | | len = = 0 | | ! bstr )
continue ;
pName = ole_wc2mb ( bstr ) ;
val = ole_variant2val ( V_UNION1 ( pVarDesc , lpvarValue ) ) ;
2009-12-26 20:51:54 -05:00
* pName = toupper ( ( int ) * pName ) ;
2002-06-01 08:34:30 -04:00
id = rb_intern ( pName ) ;
if ( rb_is_const_id ( id ) ) {
rb_define_const ( klass , pName , val ) ;
}
else {
rb_hash_aset ( constant , rb_str_new2 ( pName ) , val ) ;
}
SysFreeString ( bstr ) ;
if ( pName ) {
free ( pName ) ;
pName = NULL ;
}
}
pTypeInfo - > lpVtbl - > ReleaseVarDesc ( pTypeInfo , pVarDesc ) ;
}
pTypeInfo - > lpVtbl - > ReleaseTypeAttr ( pTypeInfo , pTypeAttr ) ;
OLE_RELEASE ( pTypeInfo ) ;
}
rb_define_const ( klass , " CONSTANTS " , constant ) ;
}
static HRESULT
2006-04-30 09:11:12 -04:00
clsid_from_remote ( VALUE host , VALUE com , CLSID * pclsid )
2002-06-01 08:34:30 -04:00
{
HKEY hlm ;
HKEY hpid ;
VALUE subkey ;
LONG err ;
char clsid [ 100 ] ;
OLECHAR * pbuf ;
DWORD len ;
DWORD dwtype ;
HRESULT hr = S_OK ;
err = RegConnectRegistry ( StringValuePtr ( host ) , HKEY_LOCAL_MACHINE , & hlm ) ;
if ( err ! = ERROR_SUCCESS )
return HRESULT_FROM_WIN32 ( err ) ;
subkey = rb_str_new2 ( " SOFTWARE \\ Classes \\ " ) ;
rb_str_concat ( subkey , com ) ;
rb_str_cat2 ( subkey , " \\ CLSID " ) ;
err = RegOpenKeyEx ( hlm , StringValuePtr ( subkey ) , 0 , KEY_READ , & hpid ) ;
if ( err ! = ERROR_SUCCESS )
hr = HRESULT_FROM_WIN32 ( err ) ;
else {
len = sizeof ( clsid ) ;
2010-11-11 07:30:39 -05:00
err = RegQueryValueEx ( hpid , " " , NULL , & dwtype , ( BYTE * ) clsid , & len ) ;
2002-06-01 08:34:30 -04:00
if ( err = = ERROR_SUCCESS & & dwtype = = REG_SZ ) {
2015-09-21 10:40:57 -04:00
pbuf = ole_mb2wc ( clsid , - 1 , cWIN32OLE_cp ) ;
2002-06-01 08:34:30 -04:00
hr = CLSIDFromString ( pbuf , pclsid ) ;
SysFreeString ( pbuf ) ;
2004-02-15 01:53:15 -05:00
}
else {
2002-06-01 08:34:30 -04:00
hr = HRESULT_FROM_WIN32 ( err ) ;
}
RegCloseKey ( hpid ) ;
}
RegCloseKey ( hlm ) ;
return hr ;
}
static VALUE
2014-08-12 08:51:36 -04:00
ole_create_dcom ( VALUE self , VALUE ole , VALUE host , VALUE others )
2002-06-01 08:34:30 -04:00
{
HRESULT hr ;
CLSID clsid ;
OLECHAR * pbuf ;
COSERVERINFO serverinfo ;
MULTI_QI multi_qi ;
DWORD clsctx = CLSCTX_REMOTE_SERVER ;
if ( ! gole32 )
gole32 = LoadLibrary ( " OLE32 " ) ;
if ( ! gole32 )
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eRuntimeError , " failed to load OLE32 " ) ;
2002-06-01 08:34:30 -04:00
if ( ! gCoCreateInstanceEx )
gCoCreateInstanceEx = ( FNCOCREATEINSTANCEEX * )
GetProcAddress ( gole32 , " CoCreateInstanceEx " ) ;
if ( ! gCoCreateInstanceEx )
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eRuntimeError , " CoCreateInstanceEx is not supported in this environment " ) ;
2002-06-01 08:34:30 -04:00
2008-06-27 19:43:57 -04:00
pbuf = ole_vstr2wc ( ole ) ;
2002-06-01 08:34:30 -04:00
hr = CLSIDFromProgID ( pbuf , & clsid ) ;
if ( FAILED ( hr ) )
hr = clsid_from_remote ( host , ole , & clsid ) ;
if ( FAILED ( hr ) )
hr = CLSIDFromString ( pbuf , & clsid ) ;
SysFreeString ( pbuf ) ;
if ( FAILED ( hr ) )
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" unknown OLE server: `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( ole ) ) ;
2010-04-22 04:04:13 -04:00
memset ( & serverinfo , 0 , sizeof ( COSERVERINFO ) ) ;
2008-06-27 19:43:57 -04:00
serverinfo . pwszName = ole_vstr2wc ( host ) ;
2002-06-01 08:34:30 -04:00
memset ( & multi_qi , 0 , sizeof ( MULTI_QI ) ) ;
multi_qi . pIID = & IID_IDispatch ;
hr = gCoCreateInstanceEx ( & clsid , NULL , clsctx , & serverinfo , 1 , & multi_qi ) ;
SysFreeString ( serverinfo . pwszName ) ;
if ( FAILED ( hr ) )
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to create DCOM server `%s' in `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( ole ) ,
StringValuePtr ( host ) ) ;
ole_set_member ( self , ( IDispatch * ) multi_qi . pItf ) ;
return self ;
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_bind_obj ( VALUE moniker , int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
IBindCtx * pBindCtx ;
IMoniker * pMoniker ;
IDispatch * pDispatch ;
2008-07-23 18:01:36 -04:00
void * p ;
2002-06-01 08:34:30 -04:00
HRESULT hr ;
OLECHAR * pbuf ;
ULONG eaten = 0 ;
2010-04-22 04:04:13 -04:00
2002-06-01 08:34:30 -04:00
ole_initialize ( ) ;
hr = CreateBindCtx ( 0 , & pBindCtx ) ;
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to create bind context " ) ;
2002-06-01 08:34:30 -04:00
}
2008-06-27 19:43:57 -04:00
pbuf = ole_vstr2wc ( moniker ) ;
2002-06-01 08:34:30 -04:00
hr = MkParseDisplayName ( pBindCtx , pbuf , & eaten , & pMoniker ) ;
SysFreeString ( pbuf ) ;
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pBindCtx ) ;
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to parse display name of moniker `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( moniker ) ) ;
}
2010-04-22 04:04:13 -04:00
hr = pMoniker - > lpVtbl - > BindToObject ( pMoniker , pBindCtx , NULL ,
2008-07-23 18:01:36 -04:00
& IID_IDispatch , & p ) ;
pDispatch = p ;
2002-06-01 08:34:30 -04:00
OLE_RELEASE ( pMoniker ) ;
OLE_RELEASE ( pBindCtx ) ;
if ( FAILED ( hr ) ) {
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to bind moniker `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( moniker ) ) ;
}
return create_win32ole_object ( self , pDispatch , argc , argv ) ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . connect ( ole ) - - > aWIN32OLE
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Returns running OLE Automation object or WIN32OLE object from moniker .
* 1 st argument should be OLE program id or class id or moniker .
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* WIN32OLE . connect ( ' Excel . Application ' ) # = > WIN32OLE object which represents running Excel .
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_connect ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
VALUE svr_name ;
VALUE others ;
HRESULT hr ;
CLSID clsid ;
OLECHAR * pBuf ;
IDispatch * pDispatch ;
2008-07-23 18:01:36 -04:00
void * p ;
2002-06-01 08:34:30 -04:00
IUnknown * pUnknown ;
/* initialize to use OLE */
ole_initialize ( ) ;
rb_scan_args ( argc , argv , " 1* " , & svr_name , & others ) ;
2014-08-25 07:18:17 -04:00
StringValue ( svr_name ) ;
2006-12-31 10:02:22 -05:00
if ( rb_safe_level ( ) > 0 & & OBJ_TAINTED ( svr_name ) ) {
2014-08-25 07:18:17 -04:00
rb_raise ( rb_eSecurityError , " insecure connection - `%s' " ,
StringValuePtr ( svr_name ) ) ;
2003-05-02 22:17:26 -04:00
}
2002-06-01 08:34:30 -04:00
/* get CLSID from OLE server name */
2008-06-27 19:43:57 -04:00
pBuf = ole_vstr2wc ( svr_name ) ;
2002-06-01 08:34:30 -04:00
hr = CLSIDFromProgID ( pBuf , & clsid ) ;
if ( FAILED ( hr ) ) {
hr = CLSIDFromString ( pBuf , & clsid ) ;
}
SysFreeString ( pBuf ) ;
if ( FAILED ( hr ) ) {
return ole_bind_obj ( svr_name , argc , argv , self ) ;
}
hr = GetActiveObject ( & clsid , 0 , & pUnknown ) ;
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
2004-10-30 02:25:00 -04:00
" OLE server `%s' not running " , StringValuePtr ( svr_name ) ) ;
2002-06-01 08:34:30 -04:00
}
2008-07-23 18:01:36 -04:00
hr = pUnknown - > lpVtbl - > QueryInterface ( pUnknown , & IID_IDispatch , & p ) ;
pDispatch = p ;
2002-06-01 08:34:30 -04:00
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pUnknown ) ;
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
" failed to create WIN32OLE server `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( svr_name ) ) ;
}
OLE_RELEASE ( pUnknown ) ;
return create_win32ole_object ( self , pDispatch , argc , argv ) ;
}
2010-04-22 04:04:13 -04:00
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . const_load ( ole , mod = WIN32OLE )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Defines the constants of OLE Automation server as mod ' s constants .
2004-11-03 06:35:27 -05:00
* The first argument is WIN32OLE object or type library name .
2004-10-30 02:25:00 -04:00
* If 2 nd argument is omitted , the default is WIN32OLE .
* The first letter of Ruby ' s constant variable name is upper case ,
* so constant variable name of WIN32OLE object is capitalized .
2010-04-22 04:04:13 -04:00
* For example , the ' xlTop ' constant of Excel is changed to ' XlTop '
2004-10-30 02:25:00 -04:00
* in WIN32OLE .
2014-01-19 00:43:23 -05:00
* If the first letter of constant variable is not [ A - Z ] , then
2004-10-30 02:25:00 -04:00
* the constant is defined as CONSTANTS hash element .
*
* module EXCEL_CONST
* end
* excel = WIN32OLE . new ( ' Excel . Application ' )
* WIN32OLE . const_load ( excel , EXCEL_CONST )
* puts EXCEL_CONST : : XlTop # = > - 4160
* puts EXCEL_CONST : : CONSTANTS [ ' _xlDialogChartSourceData ' ] # = > 541
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* WIN32OLE . const_load ( excel )
* puts WIN32OLE : : XlTop # = > - 4160
2004-11-03 06:35:27 -05:00
*
* module MSO
* end
* WIN32OLE . const_load ( ' Microsoft Office 9.0 Object Library ' , MSO )
* puts MSO : : MsoLineSingle # = > 1
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_const_load ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
VALUE ole ;
VALUE klass ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
ITypeInfo * pTypeInfo ;
ITypeLib * pTypeLib ;
unsigned int index ;
HRESULT hr ;
OLECHAR * pBuf ;
VALUE file ;
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2010-04-22 04:04:13 -04:00
2002-06-01 08:34:30 -04:00
rb_scan_args ( argc , argv , " 11 " , & ole , & klass ) ;
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( klass , T_CLASS ) & &
! RB_TYPE_P ( klass , T_MODULE ) & &
! RB_TYPE_P ( klass , T_NIL ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eTypeError , " 2nd parameter must be Class or Module " ) ;
2002-06-01 08:34:30 -04:00
}
if ( rb_obj_is_kind_of ( ole , cWIN32OLE ) ) {
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( ole ) ;
2002-06-01 08:34:30 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetTypeInfo ( pole - > pDispatch ,
0 , lcid , & pTypeInfo ) ;
if ( FAILED ( hr ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to GetTypeInfo " ) ;
2002-06-01 08:34:30 -04:00
}
hr = pTypeInfo - > lpVtbl - > GetContainingTypeLib ( pTypeInfo , & pTypeLib , & index ) ;
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pTypeInfo ) ;
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to GetContainingTypeLib " ) ;
2002-06-01 08:34:30 -04:00
}
OLE_RELEASE ( pTypeInfo ) ;
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( klass , T_NIL ) ) {
2002-06-01 08:34:30 -04:00
ole_const_load ( pTypeLib , klass , self ) ;
}
else {
ole_const_load ( pTypeLib , cWIN32OLE , self ) ;
}
OLE_RELEASE ( pTypeLib ) ;
}
2014-08-02 21:56:01 -04:00
else if ( RB_TYPE_P ( ole , T_STRING ) ) {
2002-06-01 08:34:30 -04:00
file = typelib_file ( ole ) ;
if ( file = = Qnil ) {
2004-02-15 01:53:15 -05:00
file = ole ;
2002-06-01 08:34:30 -04:00
}
2008-06-27 19:43:57 -04:00
pBuf = ole_vstr2wc ( file ) ;
2002-06-01 08:34:30 -04:00
hr = LoadTypeLibEx ( pBuf , REGKIND_NONE , & pTypeLib ) ;
SysFreeString ( pBuf ) ;
2004-02-15 01:53:15 -05:00
if ( FAILED ( hr ) )
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " failed to LoadTypeLibEx " ) ;
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( klass , T_NIL ) ) {
2002-06-01 08:34:30 -04:00
ole_const_load ( pTypeLib , klass , self ) ;
}
else {
ole_const_load ( pTypeLib , cWIN32OLE , self ) ;
}
OLE_RELEASE ( pTypeLib ) ;
}
else {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eTypeError , " 1st parameter must be WIN32OLE instance " ) ;
2002-06-01 08:34:30 -04:00
}
return Qnil ;
}
static ULONG
2006-04-30 09:11:12 -04:00
reference_count ( struct oledata * pole )
2002-06-01 08:34:30 -04:00
{
ULONG n = 0 ;
if ( pole - > pDispatch ) {
2004-02-15 01:53:15 -05:00
OLE_ADDREF ( pole - > pDispatch ) ;
2002-06-01 08:34:30 -04:00
n = OLE_RELEASE ( pole - > pDispatch ) ;
}
return n ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . ole_reference_count ( aWIN32OLE ) - - > number
2010-04-22 04:04:13 -04:00
*
* Returns reference counter of Dispatch interface of WIN32OLE object .
2004-10-30 02:25:00 -04:00
* You should not use this method because this method
* exists only for debugging WIN32OLE .
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_reference_count ( VALUE self , VALUE obj )
2002-06-01 08:34:30 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
pole = oledata_get_struct ( obj ) ;
2002-06-01 08:34:30 -04:00
return INT2NUM ( reference_count ( pole ) ) ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . ole_free ( aWIN32OLE ) - - > number
2010-04-22 04:04:13 -04:00
*
* Invokes Release method of Dispatch interface of WIN32OLE object .
2004-10-30 02:25:00 -04:00
* You should not use this method because this method
* exists only for debugging WIN32OLE .
* The return value is reference counter of OLE object .
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_free ( VALUE self , VALUE obj )
2002-06-01 08:34:30 -04:00
{
ULONG n = 0 ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
pole = oledata_get_struct ( obj ) ;
2002-06-01 08:34:30 -04:00
if ( pole - > pDispatch ) {
if ( reference_count ( pole ) > 0 ) {
n = OLE_RELEASE ( pole - > pDispatch ) ;
}
}
return INT2NUM ( n ) ;
}
static HWND
2006-04-30 09:11:12 -04:00
ole_show_help ( VALUE helpfile , VALUE helpcontext )
2002-06-01 08:34:30 -04:00
{
FNHTMLHELP * pfnHtmlHelp ;
HWND hwnd = 0 ;
if ( ! ghhctrl )
ghhctrl = LoadLibrary ( " HHCTRL.OCX " ) ;
if ( ! ghhctrl )
return hwnd ;
pfnHtmlHelp = ( FNHTMLHELP * ) GetProcAddress ( ghhctrl , " HtmlHelpA " ) ;
if ( ! pfnHtmlHelp )
return hwnd ;
2010-04-22 04:04:13 -04:00
hwnd = pfnHtmlHelp ( GetDesktopWindow ( ) , StringValuePtr ( helpfile ) ,
2002-06-01 08:34:30 -04:00
0x0f , NUM2INT ( helpcontext ) ) ;
if ( hwnd = = 0 )
2010-04-22 04:04:13 -04:00
hwnd = pfnHtmlHelp ( GetDesktopWindow ( ) , StringValuePtr ( helpfile ) ,
2002-06-01 08:34:30 -04:00
0 , NUM2INT ( helpcontext ) ) ;
return hwnd ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . ole_show_help ( obj [ , helpcontext ] )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Displays helpfile . The 1 st argument specifies WIN32OLE_TYPE
* object or WIN32OLE_METHOD object or helpfile .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
2004-11-06 06:42:35 -05:00
* typeobj = excel . ole_type
2004-10-30 02:25:00 -04:00
* WIN32OLE . ole_show_help ( typeobj )
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_show_help ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
VALUE target ;
VALUE helpcontext ;
VALUE helpfile ;
VALUE name ;
HWND hwnd ;
rb_scan_args ( argc , argv , " 11 " , & target , & helpcontext ) ;
if ( rb_obj_is_kind_of ( target , cWIN32OLE_TYPE ) | |
rb_obj_is_kind_of ( target , cWIN32OLE_METHOD ) ) {
helpfile = rb_funcall ( target , rb_intern ( " helpfile " ) , 0 ) ;
if ( strlen ( StringValuePtr ( helpfile ) ) = = 0 ) {
name = rb_ivar_get ( target , rb_intern ( " name " ) ) ;
rb_raise ( rb_eRuntimeError , " no helpfile of `%s' " ,
StringValuePtr ( name ) ) ;
}
helpcontext = rb_funcall ( target , rb_intern ( " helpcontext " ) , 0 ) ;
} else {
helpfile = target ;
}
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( helpfile , T_STRING ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eTypeError , " 1st parameter must be (String|WIN32OLE_TYPE|WIN32OLE_METHOD) " ) ;
2002-06-01 08:34:30 -04:00
}
hwnd = ole_show_help ( helpfile , helpcontext ) ;
if ( hwnd = = 0 ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eRuntimeError , " failed to open help file `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( helpfile ) ) ;
}
return Qnil ;
}
2010-04-22 04:04:13 -04:00
/*
2004-10-31 02:59:58 -05:00
* call - seq :
* WIN32OLE . codepage
2010-04-22 04:04:13 -04:00
*
2004-10-31 02:59:58 -05:00
* Returns current codepage .
* WIN32OLE . codepage # = > WIN32OLE : : CP_ACP
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_get_code_page ( VALUE self )
2004-10-31 02:59:58 -05:00
{
return INT2FIX ( cWIN32OLE_cp ) ;
}
2010-04-22 04:04:13 -04:00
static BOOL CALLBACK
2007-01-20 07:12:36 -05:00
installed_code_page_proc ( LPTSTR str ) {
2007-02-20 07:25:40 -05:00
if ( strtoul ( str , NULL , 10 ) = = g_cp_to_check ) {
2007-01-27 18:46:27 -05:00
g_cp_installed = TRUE ;
2007-01-20 07:12:36 -05:00
return FALSE ;
}
return TRUE ;
}
2010-04-22 04:04:13 -04:00
static BOOL
2007-02-03 00:41:03 -05:00
code_page_installed ( UINT cp )
{
2007-01-27 18:46:27 -05:00
g_cp_installed = FALSE ;
g_cp_to_check = cp ;
2007-01-20 07:12:36 -05:00
EnumSystemCodePages ( installed_code_page_proc , CP_INSTALLED ) ;
2007-01-27 18:46:27 -05:00
return g_cp_installed ;
2007-01-20 07:12:36 -05:00
}
2010-04-22 04:04:13 -04:00
/*
2004-10-31 02:59:58 -05:00
* call - seq :
* WIN32OLE . codepage = CP
2010-04-22 04:04:13 -04:00
*
* Sets current codepage .
* The WIN32OLE . codepage is initialized according to
2008-10-08 08:05:18 -04:00
* Encoding . default_internal .
* If Encoding . default_internal is nil then WIN32OLE . codepage
* is initialized according to Encoding . default_external .
*
2004-10-31 02:59:58 -05:00
* WIN32OLE . codepage = WIN32OLE : : CP_UTF8
2008-10-08 08:05:18 -04:00
* WIN32OLE . codepage = 65001
2004-10-31 02:59:58 -05:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_set_code_page ( VALUE self , VALUE vcp )
2004-10-31 02:59:58 -05:00
{
UINT cp = FIX2INT ( vcp ) ;
2008-10-12 05:06:45 -04:00
set_ole_codepage ( cp ) ;
2004-10-31 02:59:58 -05:00
/*
* Should this method return old codepage ?
*/
return Qnil ;
}
2007-01-29 07:41:50 -05:00
/*
* call - seq :
* WIN32OLE . locale - > locale id .
*
* Returns current locale id ( lcid ) . The default locale is
2014-07-14 06:17:40 -04:00
* WIN32OLE : : LOCALE_SYSTEM_DEFAULT .
2007-01-29 07:41:50 -05:00
*
* lcid = WIN32OLE . locale
*/
2010-04-22 04:04:13 -04:00
static VALUE
2007-01-29 07:41:50 -05:00
fole_s_get_locale ( VALUE self )
{
return INT2FIX ( cWIN32OLE_lcid ) ;
}
static BOOL
CALLBACK installed_lcid_proc ( LPTSTR str )
{
if ( strcmp ( str , g_lcid_to_check ) = = 0 ) {
g_lcid_installed = TRUE ;
return FALSE ;
}
return TRUE ;
}
static BOOL
lcid_installed ( LCID lcid )
{
g_lcid_installed = FALSE ;
2014-04-23 00:14:42 -04:00
snprintf ( g_lcid_to_check , sizeof ( g_lcid_to_check ) , " %08lx " , ( unsigned long ) lcid ) ;
2007-01-29 07:41:50 -05:00
EnumSystemLocales ( installed_lcid_proc , LCID_INSTALLED ) ;
return g_lcid_installed ;
}
/*
* call - seq :
* WIN32OLE . locale = lcid
*
* Sets current locale id ( lcid ) .
*
* WIN32OLE . locale = 1033 # set locale English ( U . S )
* obj = WIN32OLE_VARIANT . new ( " $100,000 " , WIN32OLE : : VARIANT : : VT_CY )
*
*/
2010-04-22 04:04:13 -04:00
static VALUE
2007-01-29 07:41:50 -05:00
fole_s_set_locale ( VALUE self , VALUE vlcid )
{
LCID lcid = FIX2INT ( vlcid ) ;
if ( lcid_installed ( lcid ) ) {
cWIN32OLE_lcid = lcid ;
} else {
switch ( lcid ) {
case LOCALE_SYSTEM_DEFAULT :
case LOCALE_USER_DEFAULT :
cWIN32OLE_lcid = lcid ;
break ;
default :
2007-06-09 23:06:15 -04:00
rb_raise ( eWIN32OLERuntimeError , " not installed locale: %u " , ( unsigned int ) lcid ) ;
2007-01-29 07:41:50 -05:00
}
}
return Qnil ;
}
2010-04-22 04:04:13 -04:00
/*
2006-02-11 08:00:46 -05:00
* call - seq :
* WIN32OLE . create_guid
2010-04-22 04:04:13 -04:00
*
2006-02-11 08:00:46 -05:00
* Creates GUID .
2010-04-22 04:04:13 -04:00
* WIN32OLE . create_guid # = > { 1 CB530F1 - F6B1 - 404 D - BCE6 - 1959 BF91F4A8 }
2006-02-11 08:00:46 -05:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_s_create_guid ( VALUE self )
2006-02-11 08:00:46 -05:00
{
GUID guid ;
HRESULT hr ;
OLECHAR bstr [ 80 ] ;
int len = 0 ;
hr = CoCreateGuid ( & guid ) ;
if ( FAILED ( hr ) ) {
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " failed to create GUID " ) ;
2006-02-11 08:00:46 -05:00
}
len = StringFromGUID2 ( & guid , bstr , sizeof ( bstr ) / sizeof ( OLECHAR ) ) ;
if ( len = = 0 ) {
rb_raise ( rb_eRuntimeError , " failed to create GUID(buffer over) " ) ;
}
return ole_wc2vstr ( bstr , FALSE ) ;
}
2010-01-23 06:02:17 -05:00
/*
* WIN32OLE . ole_initialize and WIN32OLE . ole_uninitialize
* are used in win32ole . rb to fix the issue bug # 2618 ( ruby - core : 27634 ) .
2014-01-19 00:43:23 -05:00
* You must not use these method .
2010-01-23 06:02:17 -05:00
*/
2014-10-03 20:09:57 -04:00
/* :nodoc: */
2010-04-22 04:04:13 -04:00
static VALUE
2010-01-23 06:02:17 -05:00
fole_s_ole_initialize ( VALUE self )
{
2013-01-17 21:23:37 -05:00
ole_initialize ( ) ;
2010-01-23 06:02:17 -05:00
return Qnil ;
}
2014-10-03 20:09:57 -04:00
/* :nodoc: */
2010-04-22 04:04:13 -04:00
static VALUE
2010-01-23 06:02:17 -05:00
fole_s_ole_uninitialize ( VALUE self )
{
2013-01-17 21:23:37 -05:00
ole_uninitialize ( ) ;
2010-01-23 06:02:17 -05:00
return Qnil ;
}
2004-05-07 23:54:51 -04:00
/*
* Document - class : WIN32OLE
*
2004-10-30 02:25:00 -04:00
* < code > WIN32OLE < / code > objects represent OLE Automation object in Ruby .
2007-01-19 03:22:45 -05:00
*
* By using WIN32OLE , you can access OLE server like VBScript .
2010-04-22 04:04:13 -04:00
*
2007-01-19 03:22:45 -05:00
* Here is sample script .
*
* require ' win32ole '
2010-04-22 04:04:13 -04:00
*
2007-01-19 03:22:45 -05:00
* excel = WIN32OLE . new ( ' Excel . Application ' )
* excel . visible = true
* workbook = excel . Workbooks . Add ( ) ;
* worksheet = workbook . Worksheets ( 1 ) ;
* worksheet . Range ( " A1:D1 " ) . value = [ " North " , " South " , " East " , " West " ] ;
* worksheet . Range ( " A2:B2 " ) . value = [ 5.2 , 10 ] ;
* worksheet . Range ( " C2 " ) . value = 8 ;
* worksheet . Range ( " D2 " ) . value = 20 ;
2010-04-22 04:04:13 -04:00
*
2007-01-19 03:22:45 -05:00
* range = worksheet . Range ( " A1:D2 " ) ;
* range . select
* chart = workbook . Charts . Add ;
2010-04-22 04:04:13 -04:00
*
2007-01-19 03:22:45 -05:00
* workbook . saved = true ;
2010-04-22 04:04:13 -04:00
*
2007-01-19 03:22:45 -05:00
* excel . ActiveWorkbook . Close ( 0 ) ;
* excel . Quit ( ) ;
*
2014-07-14 06:17:40 -04:00
* Unfortunately , Win32OLE doesn ' t support the argument passed by
* reference directly .
* Instead , Win32OLE provides WIN32OLE : : ARGV or WIN32OLE_VARIANT object .
* If you want to get the result value of argument passed by reference ,
* you can use WIN32OLE : : ARGV or WIN32OLE_VARIANT .
2007-01-19 03:22:45 -05:00
*
* oleobj . method ( arg1 , arg2 , refargv3 )
* puts WIN32OLE : : ARGV [ 2 ] # the value of refargv3 after called oleobj . method
2010-04-22 04:04:13 -04:00
*
2014-07-14 06:17:40 -04:00
* or
*
* refargv3 = WIN32OLE_VARIANT . new ( XXX ,
* WIN32OLE : : VARIANT : : VT_BYREF | WIN32OLE : : VARIANT : : VT_XXX )
* oleobj . method ( arg1 , arg2 , refargv3 )
* p refargv3 . value # the value of refargv3 after called oleobj . method .
*
2004-05-07 23:54:51 -04:00
*/
/*
* call - seq :
* WIN32OLE . new ( server , [ host ] ) - > WIN32OLE object
2010-04-22 04:04:13 -04:00
*
2004-05-07 23:54:51 -04:00
* Returns a new WIN32OLE object ( OLE Automation object ) .
* The first argument server specifies OLE Automation server .
* The first argument should be CLSID or PROGID .
2010-04-22 04:04:13 -04:00
* If second argument host specified , then returns OLE Automation
* object on host .
2004-05-07 23:54:51 -04:00
*
2004-10-30 02:25:00 -04:00
* WIN32OLE . new ( ' Excel . Application ' ) # = > Excel OLE Automation WIN32OLE object .
* WIN32OLE . new ( ' { 00024500 - 0000 - 0000 - C000 - 000000000046 } ' ) # = > Excel OLE Automation WIN32OLE object .
2004-05-07 23:54:51 -04:00
*/
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
fole_initialize ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
VALUE svr_name ;
VALUE host ;
VALUE others ;
HRESULT hr ;
CLSID clsid ;
OLECHAR * pBuf ;
IDispatch * pDispatch ;
2008-07-23 18:01:36 -04:00
void * p ;
2002-06-01 08:34:30 -04:00
rb_call_super ( 0 , 0 ) ;
rb_scan_args ( argc , argv , " 11* " , & svr_name , & host , & others ) ;
2014-08-25 07:18:17 -04:00
StringValue ( svr_name ) ;
2006-12-31 10:02:22 -05:00
if ( rb_safe_level ( ) > 0 & & OBJ_TAINTED ( svr_name ) ) {
2014-08-25 07:18:17 -04:00
rb_raise ( rb_eSecurityError , " insecure object creation - `%s' " ,
2004-02-15 01:53:15 -05:00
StringValuePtr ( svr_name ) ) ;
2003-05-02 22:17:26 -04:00
}
if ( ! NIL_P ( host ) ) {
2014-08-25 07:18:17 -04:00
StringValue ( host ) ;
2006-12-31 10:02:22 -05:00
if ( rb_safe_level ( ) > 0 & & OBJ_TAINTED ( host ) ) {
2014-08-25 07:18:17 -04:00
rb_raise ( rb_eSecurityError , " insecure object creation - `%s' " ,
StringValuePtr ( host ) ) ;
2004-02-15 01:53:15 -05:00
}
2014-08-12 08:51:36 -04:00
return ole_create_dcom ( self , svr_name , host , others ) ;
2003-05-02 22:17:26 -04:00
}
2002-06-01 08:34:30 -04:00
/* get CLSID from OLE server name */
2008-06-27 19:43:57 -04:00
pBuf = ole_vstr2wc ( svr_name ) ;
2002-06-01 08:34:30 -04:00
hr = CLSIDFromProgID ( pBuf , & clsid ) ;
if ( FAILED ( hr ) ) {
hr = CLSIDFromString ( pBuf , & clsid ) ;
}
SysFreeString ( pBuf ) ;
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" unknown OLE server: `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( svr_name ) ) ;
}
/* get IDispatch interface */
hr = CoCreateInstance ( & clsid , NULL , CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER ,
2008-07-23 18:01:36 -04:00
& IID_IDispatch , & p ) ;
pDispatch = p ;
2002-06-01 08:34:30 -04:00
if ( FAILED ( hr ) ) {
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to create WIN32OLE object from `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( svr_name ) ) ;
}
2008-07-23 18:01:36 -04:00
2002-06-01 08:34:30 -04:00
ole_set_member ( self , pDispatch ) ;
return self ;
}
2014-08-04 06:49:34 -04:00
static int
hash2named_arg ( VALUE key , VALUE val , VALUE pop )
2002-06-01 08:34:30 -04:00
{
2014-08-04 06:49:34 -04:00
struct oleparam * pOp = ( struct oleparam * ) pop ;
2002-06-01 08:34:30 -04:00
unsigned int index , i ;
index = pOp - > dp . cNamedArgs ;
2006-08-19 03:53:27 -04:00
/*---------------------------------------------
the data - type of key must be String or Symbol
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( key , T_STRING ) & & ! RB_TYPE_P ( key , T_SYMBOL ) ) {
2002-06-01 08:34:30 -04:00
/* clear name of dispatch parameters */
for ( i = 1 ; i < index + 1 ; i + + ) {
SysFreeString ( pOp - > pNamedArgs [ i ] ) ;
}
/* clear dispatch parameters */
for ( i = 0 ; i < index ; i + + ) {
VariantClear ( & ( pOp - > dp . rgvarg [ i ] ) ) ;
}
/* raise an exception */
2006-08-19 03:53:27 -04:00
rb_raise ( rb_eTypeError , " wrong argument type (expected String or Symbol) " ) ;
}
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( key , T_SYMBOL ) ) {
2015-04-13 23:36:40 -04:00
key = rb_sym2str ( key ) ;
2002-06-01 08:34:30 -04:00
}
/* pNamedArgs[0] is <method name>, so "index + 1" */
2008-06-27 19:43:57 -04:00
pOp - > pNamedArgs [ index + 1 ] = ole_vstr2wc ( key ) ;
2002-06-01 08:34:30 -04:00
VariantInit ( & ( pOp - > dp . rgvarg [ index ] ) ) ;
2014-08-04 06:49:34 -04:00
ole_val2variant ( val , & ( pOp - > dp . rgvarg [ index ] ) ) ;
2002-06-01 08:34:30 -04:00
pOp - > dp . cNamedArgs + = 1 ;
2014-08-04 06:49:34 -04:00
return ST_CONTINUE ;
2002-06-01 08:34:30 -04:00
}
2004-01-25 21:35:30 -05:00
static VALUE
2006-04-30 09:11:12 -04:00
set_argv ( VARIANTARG * realargs , unsigned int beg , unsigned int end )
2004-01-25 21:35:30 -05:00
{
VALUE argv = rb_const_get ( cWIN32OLE , rb_intern ( " ARGV " ) ) ;
Check_Type ( argv , T_ARRAY ) ;
rb_ary_clear ( argv ) ;
2004-01-26 20:35:53 -05:00
while ( end - - > beg ) {
2004-02-15 01:53:15 -05:00
rb_ary_push ( argv , ole_variant2val ( & realargs [ end ] ) ) ;
2014-07-30 08:35:15 -04:00
if ( V_VT ( & realargs [ end ] ) ! = VT_RECORD ) {
VariantClear ( & realargs [ end ] ) ;
}
2004-01-25 21:35:30 -05:00
}
return argv ;
}
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
ole_invoke ( int argc , VALUE * argv , VALUE self , USHORT wFlags , BOOL is_bracket )
2002-06-01 08:34:30 -04:00
{
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
HRESULT hr ;
VALUE cmd ;
VALUE paramS ;
VALUE param ;
VALUE obj ;
VALUE v ;
BSTR wcmdname ;
DISPID DispID ;
DISPID * pDispID ;
EXCEPINFO excepinfo ;
VARIANT result ;
VARIANTARG * realargs = NULL ;
unsigned int argErr = 0 ;
unsigned int i ;
unsigned int cNamedArgs ;
2002-08-13 08:07:33 -04:00
int n ;
2002-06-01 08:34:30 -04:00
struct oleparam op ;
memset ( & excepinfo , 0 , sizeof ( EXCEPINFO ) ) ;
VariantInit ( & result ) ;
op . dp . rgvarg = NULL ;
op . dp . rgdispidNamedArgs = NULL ;
op . dp . cNamedArgs = 0 ;
op . dp . cArgs = 0 ;
rb_scan_args ( argc , argv , " 1* " , & cmd , & paramS ) ;
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( cmd , T_STRING ) & & ! RB_TYPE_P ( cmd , T_SYMBOL ) & & ! is_bracket ) {
2008-08-03 06:43:44 -04:00
rb_raise ( rb_eTypeError , " method is wrong type (expected String or Symbol) " ) ;
}
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( cmd , T_SYMBOL ) ) {
2015-04-13 23:36:40 -04:00
cmd = rb_sym2str ( cmd ) ;
2008-08-03 06:43:44 -04:00
}
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
if ( ! pole - > pDispatch ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eRuntimeError , " failed to get dispatch interface " ) ;
2002-06-01 08:34:30 -04:00
}
2006-03-29 09:12:49 -05:00
if ( is_bracket ) {
DispID = DISPID_VALUE ;
argc + = 1 ;
2008-07-25 08:13:57 -04:00
rb_ary_unshift ( paramS , cmd ) ;
2006-03-29 09:12:49 -05:00
} else {
2008-06-27 19:43:57 -04:00
wcmdname = ole_vstr2wc ( cmd ) ;
2006-03-29 09:12:49 -05:00
hr = pole - > pDispatch - > lpVtbl - > GetIDsOfNames ( pole - > pDispatch , & IID_NULL ,
& wcmdname , 1 , lcid , & DispID ) ;
SysFreeString ( wcmdname ) ;
if ( FAILED ( hr ) ) {
2010-05-20 07:55:10 -04:00
ole_raise ( hr , rb_eNoMethodError ,
2006-03-29 09:12:49 -05:00
" unknown property or method: `%s' " ,
StringValuePtr ( cmd ) ) ;
}
2002-06-01 08:34:30 -04:00
}
/* pick up last argument of method */
param = rb_ary_entry ( paramS , argc - 2 ) ;
op . dp . cNamedArgs = 0 ;
/* if last arg is hash object */
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( param , T_HASH ) ) {
2010-04-22 04:04:13 -04:00
/*------------------------------------------
hash object = = > named dispatch parameters
2002-06-01 08:34:30 -04:00
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
2014-08-18 21:29:45 -04:00
cNamedArgs = rb_long2int ( RHASH_SIZE ( param ) ) ;
2002-06-01 08:34:30 -04:00
op . dp . cArgs = cNamedArgs + argc - 2 ;
op . pNamedArgs = ALLOCA_N ( OLECHAR * , cNamedArgs + 1 ) ;
op . dp . rgvarg = ALLOCA_N ( VARIANTARG , op . dp . cArgs ) ;
2014-08-04 06:49:34 -04:00
rb_hash_foreach ( param , hash2named_arg , ( VALUE ) & op ) ;
2002-06-01 08:34:30 -04:00
pDispID = ALLOCA_N ( DISPID , cNamedArgs + 1 ) ;
2008-06-27 19:43:57 -04:00
op . pNamedArgs [ 0 ] = ole_vstr2wc ( cmd ) ;
2002-06-01 08:34:30 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetIDsOfNames ( pole - > pDispatch ,
& IID_NULL ,
op . pNamedArgs ,
op . dp . cNamedArgs + 1 ,
lcid , pDispID ) ;
for ( i = 0 ; i < op . dp . cNamedArgs + 1 ; i + + ) {
SysFreeString ( op . pNamedArgs [ i ] ) ;
op . pNamedArgs [ i ] = NULL ;
}
if ( FAILED ( hr ) ) {
/* clear dispatch parameters */
for ( i = 0 ; i < op . dp . cArgs ; i + + ) {
VariantClear ( & op . dp . rgvarg [ i ] ) ;
}
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" failed to get named argument info: `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( cmd ) ) ;
}
op . dp . rgdispidNamedArgs = & ( pDispID [ 1 ] ) ;
}
else {
cNamedArgs = 0 ;
op . dp . cArgs = argc - 1 ;
op . pNamedArgs = ALLOCA_N ( OLECHAR * , cNamedArgs + 1 ) ;
if ( op . dp . cArgs > 0 ) {
op . dp . rgvarg = ALLOCA_N ( VARIANTARG , op . dp . cArgs ) ;
}
}
/*--------------------------------------
2010-04-22 04:04:13 -04:00
non hash args = = > dispatch parameters
2002-06-01 08:34:30 -04:00
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
if ( op . dp . cArgs > cNamedArgs ) {
realargs = ALLOCA_N ( VARIANTARG , op . dp . cArgs - cNamedArgs + 1 ) ;
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
2002-08-13 08:07:33 -04:00
n = op . dp . cArgs - i + cNamedArgs - 1 ;
2002-06-01 08:34:30 -04:00
VariantInit ( & realargs [ n ] ) ;
VariantInit ( & op . dp . rgvarg [ n ] ) ;
param = rb_ary_entry ( paramS , i - cNamedArgs ) ;
2005-08-13 08:22:12 -04:00
if ( rb_obj_is_kind_of ( param , cWIN32OLE_VARIANT ) ) {
2014-10-25 18:46:15 -04:00
ole_variant2variant ( param , & op . dp . rgvarg [ n ] ) ;
2015-01-17 21:53:18 -05:00
} else if ( rb_obj_is_kind_of ( param , cWIN32OLE_RECORD ) ) {
ole_val2variant ( param , & realargs [ n ] ) ;
op . dp . rgvarg [ n ] = realargs [ n ] ;
V_VT ( & op . dp . rgvarg [ n ] ) = VT_RECORD | VT_BYREF ;
2005-08-13 08:22:12 -04:00
} else {
ole_val2variant ( param , & realargs [ n ] ) ;
V_VT ( & op . dp . rgvarg [ n ] ) = VT_VARIANT | VT_BYREF ;
V_VARIANTREF ( & op . dp . rgvarg [ n ] ) = & realargs [ n ] ;
}
2002-06-01 08:34:30 -04:00
}
}
/* apparent you need to call propput, you need this */
if ( wFlags & DISPATCH_PROPERTYPUT ) {
if ( op . dp . cArgs = = 0 )
2007-01-27 18:46:27 -05:00
ole_raise ( ResultFromScode ( E_INVALIDARG ) , eWIN32OLERuntimeError , " argument error " ) ;
2002-06-01 08:34:30 -04:00
op . dp . cNamedArgs = 1 ;
op . dp . rgdispidNamedArgs = ALLOCA_N ( DISPID , 1 ) ;
op . dp . rgdispidNamedArgs [ 0 ] = DISPID_PROPERTYPUT ;
}
2010-04-22 04:04:13 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , DispID ,
& IID_NULL , lcid , wFlags , & op . dp ,
2002-06-01 08:34:30 -04:00
& result , & excepinfo , & argErr ) ;
2004-11-03 06:35:27 -05:00
2002-06-01 08:34:30 -04:00
if ( FAILED ( hr ) ) {
2002-08-13 08:07:33 -04:00
/* retry to call args by value */
2007-11-17 10:04:55 -05:00
if ( op . dp . cArgs > = cNamedArgs ) {
2002-08-13 08:07:33 -04:00
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
n = op . dp . cArgs - i + cNamedArgs - 1 ;
param = rb_ary_entry ( paramS , i - cNamedArgs ) ;
ole_val2variant ( param , & op . dp . rgvarg [ n ] ) ;
}
2008-06-24 09:11:21 -04:00
if ( hr = = DISP_E_EXCEPTION ) {
ole_freeexceptinfo ( & excepinfo ) ;
}
2002-08-13 08:07:33 -04:00
memset ( & excepinfo , 0 , sizeof ( EXCEPINFO ) ) ;
2004-10-19 07:40:33 -04:00
VariantInit ( & result ) ;
2010-04-22 04:04:13 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , DispID ,
2002-08-13 08:07:33 -04:00
& IID_NULL , lcid , wFlags ,
2004-10-19 07:40:33 -04:00
& op . dp , & result ,
2002-08-13 08:07:33 -04:00
& excepinfo , & argErr ) ;
2004-11-03 06:35:27 -05:00
2006-06-25 04:21:29 -04:00
/* mega kludge. if a method in WORD is called and we ask
* for a result when one is not returned then
* hResult = = DISP_E_EXCEPTION . this only happens on
* functions whose DISPID > 0x8000 */
if ( ( hr = = DISP_E_EXCEPTION | | hr = = DISP_E_MEMBERNOTFOUND ) & & DispID > 0x8000 ) {
2008-06-24 09:11:21 -04:00
if ( hr = = DISP_E_EXCEPTION ) {
ole_freeexceptinfo ( & excepinfo ) ;
}
2006-06-25 04:21:29 -04:00
memset ( & excepinfo , 0 , sizeof ( EXCEPINFO ) ) ;
2010-04-22 04:04:13 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , DispID ,
2006-06-25 04:21:29 -04:00
& IID_NULL , lcid , wFlags ,
& op . dp , NULL ,
& excepinfo , & argErr ) ;
}
2002-08-13 08:07:33 -04:00
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
n = op . dp . cArgs - i + cNamedArgs - 1 ;
2014-07-30 08:35:15 -04:00
if ( V_VT ( & op . dp . rgvarg [ n ] ) ! = VT_RECORD ) {
VariantClear ( & op . dp . rgvarg [ n ] ) ;
}
2002-08-13 08:07:33 -04:00
}
}
2005-04-15 09:05:01 -04:00
if ( FAILED ( hr ) ) {
/* retry after converting nil to VT_EMPTY */
if ( op . dp . cArgs > cNamedArgs ) {
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
n = op . dp . cArgs - i + cNamedArgs - 1 ;
param = rb_ary_entry ( paramS , i - cNamedArgs ) ;
ole_val2variant2 ( param , & op . dp . rgvarg [ n ] ) ;
}
2008-06-24 09:11:21 -04:00
if ( hr = = DISP_E_EXCEPTION ) {
ole_freeexceptinfo ( & excepinfo ) ;
}
2005-04-15 09:05:01 -04:00
memset ( & excepinfo , 0 , sizeof ( EXCEPINFO ) ) ;
VariantInit ( & result ) ;
2010-04-22 04:04:13 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , DispID ,
2005-04-15 09:05:01 -04:00
& IID_NULL , lcid , wFlags ,
& op . dp , & result ,
& excepinfo , & argErr ) ;
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
n = op . dp . cArgs - i + cNamedArgs - 1 ;
2014-08-05 06:31:00 -04:00
if ( V_VT ( & op . dp . rgvarg [ n ] ) ! = VT_RECORD ) {
VariantClear ( & op . dp . rgvarg [ n ] ) ;
}
2005-04-15 09:05:01 -04:00
}
}
}
2002-06-01 08:34:30 -04:00
}
/* clear dispatch parameter */
if ( op . dp . cArgs > cNamedArgs ) {
2007-01-26 10:03:43 -05:00
for ( i = cNamedArgs ; i < op . dp . cArgs ; i + + ) {
n = op . dp . cArgs - i + cNamedArgs - 1 ;
param = rb_ary_entry ( paramS , i - cNamedArgs ) ;
if ( rb_obj_is_kind_of ( param , cWIN32OLE_VARIANT ) ) {
ole_val2variant ( param , & realargs [ n ] ) ;
2014-07-30 08:35:15 -04:00
} else if ( rb_obj_is_kind_of ( param , cWIN32OLE_RECORD ) & &
V_VT ( & realargs [ n ] ) = = VT_RECORD ) {
olerecord_set_ivar ( param , V_RECORDINFO ( & realargs [ n ] ) , V_RECORD ( & realargs [ n ] ) ) ;
2007-01-26 10:03:43 -05:00
}
}
2004-02-15 01:53:15 -05:00
set_argv ( realargs , cNamedArgs , op . dp . cArgs ) ;
2002-06-01 08:34:30 -04:00
}
else {
for ( i = 0 ; i < op . dp . cArgs ; i + + ) {
VariantClear ( & op . dp . rgvarg [ i ] ) ;
}
}
if ( FAILED ( hr ) ) {
v = ole_excepinfo2msg ( & excepinfo ) ;
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " (in OLE method `%s': )%s " ,
2007-01-19 21:28:49 -05:00
StringValuePtr ( cmd ) ,
2006-12-27 07:00:54 -05:00
StringValuePtr ( v ) ) ;
2002-06-01 08:34:30 -04:00
}
obj = ole_variant2val ( & result ) ;
VariantClear ( & result ) ;
return obj ;
}
2004-05-07 23:54:51 -04:00
/*
* call - seq :
* WIN32OLE # invoke ( method , [ arg1 , . . . ] ) = > return value of method .
*
2010-04-22 04:04:13 -04:00
* Runs OLE method .
2004-05-07 23:54:51 -04:00
* The first argument specifies the method name of OLE Automation object .
* The others specify argument of the < i > method < / i > .
2004-10-30 02:25:00 -04:00
* If you can not execute < i > method < / i > directly , then use this method instead .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* excel . invoke ( ' Quit ' ) # = > same as excel . Quit
2004-05-07 23:54:51 -04:00
*
*/
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
fole_invoke ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
2006-03-29 09:12:49 -05:00
return ole_invoke ( argc , argv , self , DISPATCH_METHOD | DISPATCH_PROPERTYGET , FALSE ) ;
2002-06-01 08:34:30 -04:00
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_invoke2 ( VALUE self , VALUE dispid , VALUE args , VALUE types , USHORT dispkind )
2002-06-01 08:34:30 -04:00
{
HRESULT hr ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
unsigned int argErr = 0 ;
EXCEPINFO excepinfo ;
VARIANT result ;
DISPPARAMS dispParams ;
VARIANTARG * realargs = NULL ;
int i , j ;
VALUE obj = Qnil ;
VALUE tp , param ;
VALUE v ;
VARTYPE vt ;
Check_Type ( args , T_ARRAY ) ;
Check_Type ( types , T_ARRAY ) ;
2010-04-22 04:04:13 -04:00
2002-06-01 08:34:30 -04:00
memset ( & excepinfo , 0 , sizeof ( EXCEPINFO ) ) ;
memset ( & dispParams , 0 , sizeof ( DISPPARAMS ) ) ;
VariantInit ( & result ) ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
2006-09-02 10:42:08 -04:00
dispParams . cArgs = RARRAY_LEN ( args ) ;
2002-06-01 08:34:30 -04:00
dispParams . rgvarg = ALLOCA_N ( VARIANTARG , dispParams . cArgs ) ;
realargs = ALLOCA_N ( VARIANTARG , dispParams . cArgs ) ;
for ( i = 0 , j = dispParams . cArgs - 1 ; i < ( int ) dispParams . cArgs ; i + + , j - - )
{
2004-02-15 01:53:15 -05:00
VariantInit ( & realargs [ i ] ) ;
VariantInit ( & dispParams . rgvarg [ i ] ) ;
tp = rb_ary_entry ( types , j ) ;
vt = ( VARTYPE ) FIX2INT ( tp ) ;
V_VT ( & dispParams . rgvarg [ i ] ) = vt ;
param = rb_ary_entry ( args , j ) ;
if ( param = = Qnil )
{
V_VT ( & dispParams . rgvarg [ i ] ) = V_VT ( & realargs [ i ] ) = VT_ERROR ;
V_ERROR ( & dispParams . rgvarg [ i ] ) = V_ERROR ( & realargs [ i ] ) = DISP_E_PARAMNOTFOUND ;
}
else
{
if ( vt & VT_ARRAY )
{
int ent ;
LPBYTE pb ;
short * ps ;
LPLONG pl ;
VARIANT * pv ;
CY * py ;
VARTYPE v ;
SAFEARRAYBOUND rgsabound [ 1 ] ;
Check_Type ( param , T_ARRAY ) ;
rgsabound [ 0 ] . lLbound = 0 ;
2006-09-02 10:42:08 -04:00
rgsabound [ 0 ] . cElements = RARRAY_LEN ( param ) ;
2004-02-15 01:53:15 -05:00
v = vt & ~ ( VT_ARRAY | VT_BYREF ) ;
V_ARRAY ( & realargs [ i ] ) = SafeArrayCreate ( v , 1 , rgsabound ) ;
V_VT ( & realargs [ i ] ) = VT_ARRAY | v ;
SafeArrayLock ( V_ARRAY ( & realargs [ i ] ) ) ;
pb = V_ARRAY ( & realargs [ i ] ) - > pvData ;
ps = V_ARRAY ( & realargs [ i ] ) - > pvData ;
pl = V_ARRAY ( & realargs [ i ] ) - > pvData ;
py = V_ARRAY ( & realargs [ i ] ) - > pvData ;
pv = V_ARRAY ( & realargs [ i ] ) - > pvData ;
for ( ent = 0 ; ent < ( int ) rgsabound [ 0 ] . cElements ; ent + + )
{
VARIANT velem ;
VALUE elem = rb_ary_entry ( param , ent ) ;
ole_val2variant ( elem , & velem ) ;
if ( v ! = VT_VARIANT )
{
VariantChangeTypeEx ( & velem , & velem ,
2007-01-29 07:41:50 -05:00
cWIN32OLE_lcid , 0 , v ) ;
2004-02-15 01:53:15 -05:00
}
switch ( v )
{
/* 128 bits */
case VT_VARIANT :
* pv + + = velem ;
break ;
/* 64 bits */
case VT_R8 :
case VT_CY :
case VT_DATE :
* py + + = V_CY ( & velem ) ;
break ;
/* 16 bits */
case VT_BOOL :
case VT_I2 :
case VT_UI2 :
* ps + + = V_I2 ( & velem ) ;
break ;
/* 8 bites */
case VT_UI1 :
case VT_I1 :
* pb + + = V_UI1 ( & velem ) ;
break ;
/* 32 bits */
default :
* pl + + = V_I4 ( & velem ) ;
break ;
}
}
SafeArrayUnlock ( V_ARRAY ( & realargs [ i ] ) ) ;
}
else
{
ole_val2variant ( param , & realargs [ i ] ) ;
if ( ( vt & ( ~ VT_BYREF ) ) ! = VT_VARIANT )
{
hr = VariantChangeTypeEx ( & realargs [ i ] , & realargs [ i ] ,
2007-01-29 07:41:50 -05:00
cWIN32OLE_lcid , 0 ,
2004-02-15 01:53:15 -05:00
( VARTYPE ) ( vt & ( ~ VT_BYREF ) ) ) ;
if ( hr ! = S_OK )
{
rb_raise ( rb_eTypeError , " not valid value " ) ;
}
}
}
if ( ( vt & VT_BYREF ) | | vt = = VT_VARIANT )
{
if ( vt = = VT_VARIANT )
V_VT ( & dispParams . rgvarg [ i ] ) = VT_VARIANT | VT_BYREF ;
switch ( vt & ( ~ VT_BYREF ) )
{
/* 128 bits */
case VT_VARIANT :
V_VARIANTREF ( & dispParams . rgvarg [ i ] ) = & realargs [ i ] ;
break ;
/* 64 bits */
case VT_R8 :
case VT_CY :
case VT_DATE :
V_CYREF ( & dispParams . rgvarg [ i ] ) = & V_CY ( & realargs [ i ] ) ;
break ;
/* 16 bits */
case VT_BOOL :
case VT_I2 :
case VT_UI2 :
V_I2REF ( & dispParams . rgvarg [ i ] ) = & V_I2 ( & realargs [ i ] ) ;
break ;
/* 8 bites */
case VT_UI1 :
case VT_I1 :
V_UI1REF ( & dispParams . rgvarg [ i ] ) = & V_UI1 ( & realargs [ i ] ) ;
break ;
/* 32 bits */
default :
V_I4REF ( & dispParams . rgvarg [ i ] ) = & V_I4 ( & realargs [ i ] ) ;
break ;
}
}
else
{
/* copy 64 bits of data */
V_CY ( & dispParams . rgvarg [ i ] ) = V_CY ( & realargs [ i ] ) ;
}
}
2002-06-01 08:34:30 -04:00
}
if ( dispkind & DISPATCH_PROPERTYPUT ) {
dispParams . cNamedArgs = 1 ;
dispParams . rgdispidNamedArgs = ALLOCA_N ( DISPID , 1 ) ;
dispParams . rgdispidNamedArgs [ 0 ] = DISPID_PROPERTYPUT ;
}
2005-07-09 09:03:10 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , NUM2INT ( dispid ) ,
2007-01-29 07:41:50 -05:00
& IID_NULL , cWIN32OLE_lcid ,
2002-06-01 08:34:30 -04:00
dispkind ,
& dispParams , & result ,
& excepinfo , & argErr ) ;
if ( FAILED ( hr ) ) {
v = ole_excepinfo2msg ( & excepinfo ) ;
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " (in OLE method `<dispatch id:%d>': )%s " ,
2007-01-19 21:28:49 -05:00
NUM2INT ( dispid ) ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( v ) ) ;
}
/* clear dispatch parameter */
if ( dispParams . cArgs > 0 ) {
2004-02-15 01:53:15 -05:00
set_argv ( realargs , 0 , dispParams . cArgs ) ;
2002-06-01 08:34:30 -04:00
}
obj = ole_variant2val ( & result ) ;
VariantClear ( & result ) ;
return obj ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # _invoke ( dispid , args , types )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Runs the early binding method .
2010-04-22 04:04:13 -04:00
* The 1 st argument specifies dispatch ID ,
2004-10-30 02:25:00 -04:00
* the 2 nd argument specifies the array of arguments ,
* the 3 rd argument specifies the array of the type of arguments .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* excel . _invoke ( 302 , [ ] , [ ] ) # same effect as excel . Quit
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_invoke2 ( VALUE self , VALUE dispid , VALUE args , VALUE types )
2002-06-01 08:34:30 -04:00
{
return ole_invoke2 ( self , dispid , args , types , DISPATCH_METHOD ) ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # _getproperty ( dispid , args , types )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Runs the early binding method to get property .
2010-04-22 04:04:13 -04:00
* The 1 st argument specifies dispatch ID ,
2004-10-30 02:25:00 -04:00
* the 2 nd argument specifies the array of arguments ,
* the 3 rd argument specifies the array of the type of arguments .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* puts excel . _getproperty ( 558 , [ ] , [ ] ) # same effect as puts excel . visible
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_getproperty2 ( VALUE self , VALUE dispid , VALUE args , VALUE types )
2002-06-01 08:34:30 -04:00
{
return ole_invoke2 ( self , dispid , args , types , DISPATCH_PROPERTYGET ) ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # _setproperty ( dispid , args , types )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Runs the early binding method to set property .
2010-04-22 04:04:13 -04:00
* The 1 st argument specifies dispatch ID ,
2004-10-30 02:25:00 -04:00
* the 2 nd argument specifies the array of arguments ,
* the 3 rd argument specifies the array of the type of arguments .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* excel . _setproperty ( 558 , [ true ] , [ WIN32OLE : : VARIANT : : VT_BOOL ] ) # same effect as excel . visible = true
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_setproperty2 ( VALUE self , VALUE dispid , VALUE args , VALUE types )
2002-06-01 08:34:30 -04:00
{
return ole_invoke2 ( self , dispid , args , types , DISPATCH_PROPERTYPUT ) ;
}
2006-03-29 09:12:49 -05:00
/*
* call - seq :
2010-04-22 04:04:13 -04:00
* WIN32OLE [ a1 , a2 , . . . ] = val
*
2007-01-07 03:56:04 -05:00
* Sets the value to WIN32OLE object specified by a1 , a2 , . . .
2010-04-22 04:04:13 -04:00
*
2007-01-07 03:56:04 -05:00
* dict = WIN32OLE . new ( ' Scripting . Dictionary ' )
* dict . add ( ' ruby ' , ' RUBY ' )
2010-04-22 04:04:13 -04:00
* dict [ ' ruby ' ] = ' Ruby '
2007-01-07 03:56:04 -05:00
* puts dict [ ' ruby ' ] # = > ' Ruby '
*
* Remark : You can not use this method to set the property value .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* # excel [ ' Visible ' ] = true # This is error ! ! !
* excel . Visible = true # You should to use this style to set the property .
2006-03-29 09:12:49 -05:00
*
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_setproperty_with_bracket ( int argc , VALUE * argv , VALUE self )
2006-03-29 09:12:49 -05:00
{
return ole_invoke ( argc , argv , self , DISPATCH_PROPERTYPUT , TRUE ) ;
}
2002-06-01 08:34:30 -04:00
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE . setproperty ( ' property ' , [ arg1 , arg2 , . . . ] val )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Sets property of OLE object .
* When you want to set property with argument , you can use this method .
2002-06-01 08:34:30 -04:00
*
2004-10-30 02:25:00 -04:00
* excel = WIN32OLE . new ( ' Excel . Application ' )
2006-03-29 09:12:49 -05:00
* excel . Visible = true
2004-10-30 02:25:00 -04:00
* book = excel . workbooks . add
* sheet = book . worksheets ( 1 )
* sheet . setproperty ( ' Cells ' , 1 , 2 , 10 ) # = > The B1 cell value is 10.
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_setproperty ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
2006-03-29 09:12:49 -05:00
return ole_invoke ( argc , argv , self , DISPATCH_PROPERTYPUT , FALSE ) ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
2010-04-22 04:04:13 -04:00
* WIN32OLE [ a1 , a2 , . . . ]
*
2007-01-07 03:56:04 -05:00
* Returns the value of Collection specified by a1 , a2 , . . . .
2004-10-30 02:25:00 -04:00
*
2007-01-07 03:56:04 -05:00
* dict = WIN32OLE . new ( ' Scripting . Dictionary ' )
* dict . add ( ' ruby ' , ' Ruby ' )
* puts dict [ ' ruby ' ] # = > ' Ruby ' ( same as ` puts dict . item ( ' ruby ' ) ' )
2010-04-22 04:04:13 -04:00
*
2007-01-07 03:56:04 -05:00
* Remark : You can not use this method to get the property .
2004-10-30 02:25:00 -04:00
* excel = WIN32OLE . new ( ' Excel . Application ' )
2007-01-07 03:56:04 -05:00
* # puts excel [ ' Visible ' ] This is error ! ! !
* puts excel . Visible # You should to use this style to get the property .
*
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_getproperty_with_bracket ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
2006-03-29 09:12:49 -05:00
return ole_invoke ( argc , argv , self , DISPATCH_PROPERTYGET , TRUE ) ;
2002-06-01 08:34:30 -04:00
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_propertyput ( VALUE self , VALUE property , VALUE value )
2002-06-01 08:34:30 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
unsigned argErr ;
unsigned int index ;
HRESULT hr ;
EXCEPINFO excepinfo ;
DISPID dispID = DISPID_VALUE ;
DISPID dispIDParam = DISPID_PROPERTYPUT ;
2006-06-18 07:34:53 -04:00
USHORT wFlags = DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF ;
2002-06-01 08:34:30 -04:00
DISPPARAMS dispParams ;
VARIANTARG propertyValue [ 2 ] ;
OLECHAR * pBuf [ 1 ] ;
VALUE v ;
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2002-06-01 08:34:30 -04:00
dispParams . rgdispidNamedArgs = & dispIDParam ;
dispParams . rgvarg = propertyValue ;
dispParams . cNamedArgs = 1 ;
dispParams . cArgs = 1 ;
VariantInit ( & propertyValue [ 0 ] ) ;
VariantInit ( & propertyValue [ 1 ] ) ;
memset ( & excepinfo , 0 , sizeof ( excepinfo ) ) ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
/* get ID from property name */
2008-06-27 19:43:57 -04:00
pBuf [ 0 ] = ole_vstr2wc ( property ) ;
2002-06-01 08:34:30 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetIDsOfNames ( pole - > pDispatch , & IID_NULL ,
pBuf , 1 , lcid , & dispID ) ;
SysFreeString ( pBuf [ 0 ] ) ;
pBuf [ 0 ] = NULL ;
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
" unknown property or method: `%s' " ,
2002-06-01 08:34:30 -04:00
StringValuePtr ( property ) ) ;
}
/* set property value */
ole_val2variant ( value , & propertyValue [ 0 ] ) ;
2010-04-22 04:04:13 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , dispID , & IID_NULL ,
2002-06-01 08:34:30 -04:00
lcid , wFlags , & dispParams ,
NULL , & excepinfo , & argErr ) ;
for ( index = 0 ; index < dispParams . cArgs ; + + index ) {
VariantClear ( & propertyValue [ index ] ) ;
}
if ( FAILED ( hr ) ) {
v = ole_excepinfo2msg ( & excepinfo ) ;
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " (in setting property `%s': )%s " ,
2007-01-19 21:28:49 -05:00
StringValuePtr ( property ) ,
StringValuePtr ( v ) ) ;
2002-06-01 08:34:30 -04:00
}
return Qnil ;
}
2004-05-07 23:54:51 -04:00
/*
* call - seq :
* WIN32OLE # ole_free
*
* invokes Release method of Dispatch interface of WIN32OLE object .
* Usually , you do not need to call this method because Release method
* called automatically when WIN32OLE object garbaged .
*
*/
2002-08-10 08:19:16 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
fole_free ( VALUE self )
2002-08-10 08:19:16 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
pole = oledata_get_struct ( self ) ;
2002-08-10 08:19:16 -04:00
OLE_FREE ( pole - > pDispatch ) ;
pole - > pDispatch = NULL ;
return Qnil ;
}
2002-09-01 04:14:11 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
ole_each_sub ( VALUE pEnumV )
2002-09-01 04:14:11 -04:00
{
VARIANT variant ;
VALUE obj = Qnil ;
IEnumVARIANT * pEnum = ( IEnumVARIANT * ) pEnumV ;
VariantInit ( & variant ) ;
while ( pEnum - > lpVtbl - > Next ( pEnum , 1 , & variant , NULL ) = = S_OK ) {
obj = ole_variant2val ( & variant ) ;
VariantClear ( & variant ) ;
VariantInit ( & variant ) ;
2004-02-15 01:53:15 -05:00
rb_yield ( obj ) ;
2002-09-01 04:14:11 -04:00
}
return Qnil ;
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_ienum_free ( VALUE pEnumV )
2002-09-01 04:14:11 -04:00
{
IEnumVARIANT * pEnum = ( IEnumVARIANT * ) pEnumV ;
OLE_RELEASE ( pEnum ) ;
return Qnil ;
}
2002-06-01 08:34:30 -04:00
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # each { | i | . . . }
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Iterates over each item of OLE collection which has IEnumVARIANT interface .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* book = excel . workbooks . add
* sheets = book . worksheets ( 1 )
* cells = sheets . cells ( " A1:A5 " )
* cells . each do | cell |
* cell . value = 10
* end
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_each ( VALUE self )
2002-06-01 08:34:30 -04:00
{
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2002-06-01 08:34:30 -04:00
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
unsigned int argErr ;
EXCEPINFO excepinfo ;
DISPPARAMS dispParams ;
2002-09-01 04:14:11 -04:00
VARIANT result ;
2002-06-01 08:34:30 -04:00
HRESULT hr ;
IEnumVARIANT * pEnum = NULL ;
2008-07-23 18:01:36 -04:00
void * p ;
2002-06-01 08:34:30 -04:00
* ext/dbm/dbm.c (fdbm_each_value, fdbm_each_key, fdbm_each_pair):
GDBM#{each,each_pair,each_key,each_value}: Return an enumerator
if no block is given.
* ext/gdbm/gdbm.c (fgdbm_each_value, fgdbm_each_key,
fgdbm_each_pair): GDBM#{each,each_pair,each_key,each_value}:
Return an enumerator if no block is given.
* ext/openssl/ossl_config.c (ossl_config_each):
OpenSSL::Config#each: Return an enumerator if no block is given.
* ext/readline/readline.c (hist_each): Readline::HISTORY#each:
Return an enumerator if no block is given.
* ext/sdbm/init.c (fsdbm_each_value, fsdbm_each_key,
fsdbm_each_pair): SDBM#{each,each_pair,each_key,each_value}:
Return an enumerator if no block is given.
* ext/stringio/stringio.c (strio_each_byte, strio_each):
StringIO#{each,each_line,each_byte}: Return an enumerator if no
block is given.
* ext/stringio/stringio.c (Init_stringio): Add #lines and #bytes,
which are aliases to #each_line and #each_byte, respectively.
* ext/win32ole/win32ole.c (fole_each): WIN32OLE#each: Return an
enumerator if no block is given.
* ext/zlib/zlib.c (rb_gzreader_each_byte, rb_gzreader_each):
Zlib::GzipReader#{each,each_line,each_byte}: Return an
enumerator if no block is given.
* ext/zlib/zlib.c (Init_zlib): Add Zlib::GzipReader#lines and
#bytes, which are aliases to #each_line and #each_byte,
respectively.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 04:48:33 -04:00
RETURN_ENUMERATOR ( self , 0 , 0 ) ;
2002-06-01 08:34:30 -04:00
VariantInit ( & result ) ;
dispParams . rgvarg = NULL ;
dispParams . rgdispidNamedArgs = NULL ;
dispParams . cNamedArgs = 0 ;
dispParams . cArgs = 0 ;
memset ( & excepinfo , 0 , sizeof ( excepinfo ) ) ;
2010-04-22 04:04:13 -04:00
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
hr = pole - > pDispatch - > lpVtbl - > Invoke ( pole - > pDispatch , DISPID_NEWENUM ,
& IID_NULL , lcid ,
DISPATCH_METHOD | DISPATCH_PROPERTYGET ,
& dispParams , & result ,
& excepinfo , & argErr ) ;
if ( FAILED ( hr ) ) {
VariantClear ( & result ) ;
2007-01-27 18:46:27 -05:00
ole_raise ( hr , eWIN32OLERuntimeError , " failed to get IEnum Interface " ) ;
2002-06-01 08:34:30 -04:00
}
2008-07-23 18:01:36 -04:00
if ( V_VT ( & result ) = = VT_UNKNOWN ) {
2002-06-01 08:34:30 -04:00
hr = V_UNKNOWN ( & result ) - > lpVtbl - > QueryInterface ( V_UNKNOWN ( & result ) ,
& IID_IEnumVARIANT ,
2008-07-23 18:01:36 -04:00
& p ) ;
pEnum = p ;
} else if ( V_VT ( & result ) = = VT_DISPATCH ) {
2002-06-01 08:34:30 -04:00
hr = V_DISPATCH ( & result ) - > lpVtbl - > QueryInterface ( V_DISPATCH ( & result ) ,
& IID_IEnumVARIANT ,
2008-07-23 18:01:36 -04:00
& p ) ;
pEnum = p ;
}
2002-06-01 08:34:30 -04:00
if ( FAILED ( hr ) | | ! pEnum ) {
VariantClear ( & result ) ;
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to get IEnum Interface " ) ;
2002-06-01 08:34:30 -04:00
}
VariantClear ( & result ) ;
2002-09-01 04:14:11 -04:00
rb_ensure ( ole_each_sub , ( VALUE ) pEnum , ole_ienum_free , ( VALUE ) pEnum ) ;
2002-06-01 08:34:30 -04:00
return Qnil ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # method_missing ( id [ , arg1 , arg2 , . . . ] )
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Calls WIN32OLE # invoke method .
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_missing ( int argc , VALUE * argv , VALUE self )
2002-06-01 08:34:30 -04:00
{
2015-09-21 11:29:20 -04:00
VALUE mid , sym ;
2006-06-09 19:18:04 -04:00
const char * mname ;
2015-09-21 11:29:20 -04:00
long n ;
2013-04-08 04:19:32 -04:00
rb_check_arity ( argc , 1 , UNLIMITED_ARGUMENTS ) ;
2015-09-21 11:29:20 -04:00
mid = argv [ 0 ] ;
sym = rb_check_symbol ( & mid ) ;
2015-09-21 11:46:44 -04:00
if ( ! NIL_P ( sym ) ) mid = rb_sym2str ( sym ) ;
2015-09-21 11:29:20 -04:00
mname = StringValueCStr ( mid ) ;
2002-06-01 08:34:30 -04:00
if ( ! mname ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
rb_raise ( rb_eRuntimeError , " fail: unknown method or property " ) ;
2002-06-01 08:34:30 -04:00
}
2015-09-21 11:29:20 -04:00
n = RSTRING_LEN ( mid ) ;
2013-08-23 04:17:53 -04:00
# if SIZEOF_SIZE_T > SIZEOF_LONG
if ( n > = LONG_MAX ) {
rb_raise ( rb_eRuntimeError , " too long method or property name " ) ;
}
# endif
2002-06-01 08:34:30 -04:00
if ( mname [ n - 1 ] = = ' = ' ) {
2013-04-08 04:19:32 -04:00
rb_check_arity ( argc , 2 , 2 ) ;
2015-09-21 11:29:20 -04:00
argv [ 0 ] = rb_enc_str_new ( mname , ( n - 1 ) , cWIN32OLE_enc ) ;
2002-06-01 08:34:30 -04:00
return ole_propertyput ( self , argv [ 0 ] , argv [ 1 ] ) ;
}
else {
2015-09-21 11:29:20 -04:00
argv [ 0 ] = rb_enc_str_new ( mname , n , cWIN32OLE_enc ) ;
2006-03-29 09:12:49 -05:00
return ole_invoke ( argc , argv , self , DISPATCH_METHOD | DISPATCH_PROPERTYGET , FALSE ) ;
2002-06-01 08:34:30 -04:00
}
}
2002-08-10 08:19:16 -04:00
static HRESULT
2006-04-30 09:11:12 -04:00
typeinfo_from_ole ( struct oledata * pole , ITypeInfo * * ppti )
2002-08-10 08:19:16 -04:00
{
ITypeInfo * pTypeInfo ;
ITypeLib * pTypeLib ;
BSTR bstr ;
VALUE type ;
UINT i ;
UINT count ;
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2002-08-10 08:19:16 -04:00
HRESULT hr = pole - > pDispatch - > lpVtbl - > GetTypeInfo ( pole - > pDispatch ,
0 , lcid , & pTypeInfo ) ;
if ( FAILED ( hr ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to GetTypeInfo " ) ;
2002-08-10 08:19:16 -04:00
}
hr = pTypeInfo - > lpVtbl - > GetDocumentation ( pTypeInfo ,
- 1 ,
& bstr ,
NULL , NULL , NULL ) ;
type = WC2VSTR ( bstr ) ;
hr = pTypeInfo - > lpVtbl - > GetContainingTypeLib ( pTypeInfo , & pTypeLib , & i ) ;
OLE_RELEASE ( pTypeInfo ) ;
if ( FAILED ( hr ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to GetContainingTypeLib " ) ;
2002-08-10 08:19:16 -04:00
}
count = pTypeLib - > lpVtbl - > GetTypeInfoCount ( pTypeLib ) ;
for ( i = 0 ; i < count ; i + + ) {
hr = pTypeLib - > lpVtbl - > GetDocumentation ( pTypeLib , i ,
& bstr , NULL , NULL , NULL ) ;
if ( SUCCEEDED ( hr ) & & rb_str_cmp ( WC2VSTR ( bstr ) , type ) = = 0 ) {
hr = pTypeLib - > lpVtbl - > GetTypeInfo ( pTypeLib , i , & pTypeInfo ) ;
if ( SUCCEEDED ( hr ) ) {
* ppti = pTypeInfo ;
break ;
}
}
}
OLE_RELEASE ( pTypeLib ) ;
return hr ;
}
2002-06-01 08:34:30 -04:00
static VALUE
2006-04-30 09:11:12 -04:00
ole_methods ( VALUE self , int mask )
2002-06-01 08:34:30 -04:00
{
ITypeInfo * pTypeInfo ;
HRESULT hr ;
VALUE methods ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2002-06-01 08:34:30 -04:00
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
methods = rb_ary_new ( ) ;
2002-08-10 08:19:16 -04:00
hr = typeinfo_from_ole ( pole , & pTypeInfo ) ;
if ( FAILED ( hr ) )
2002-06-01 08:34:30 -04:00
return methods ;
2002-08-10 08:19:16 -04:00
rb_ary_concat ( methods , ole_methods_from_typeinfo ( pTypeInfo , mask ) ) ;
OLE_RELEASE ( pTypeInfo ) ;
2002-06-01 08:34:30 -04:00
return methods ;
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # ole_methods
2010-04-22 04:04:13 -04:00
*
* Returns the array of WIN32OLE_METHOD object .
2004-10-30 02:25:00 -04:00
* The element is OLE method of WIN32OLE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* methods = excel . ole_methods
2010-04-22 04:04:13 -04:00
*
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_methods ( VALUE self )
2002-06-01 08:34:30 -04:00
{
2006-06-18 07:34:53 -04:00
return ole_methods ( self , INVOKE_FUNC | INVOKE_PROPERTYGET | INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF ) ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # ole_get_methods
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Returns the array of WIN32OLE_METHOD object .
* The element of the array is property ( gettable ) of WIN32OLE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* properties = excel . ole_get_methods
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_get_methods ( VALUE self )
2002-06-01 08:34:30 -04:00
{
2004-10-19 07:40:33 -04:00
return ole_methods ( self , INVOKE_PROPERTYGET ) ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # ole_put_methods
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Returns the array of WIN32OLE_METHOD object .
* The element of the array is property ( settable ) of WIN32OLE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* properties = excel . ole_put_methods
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_put_methods ( VALUE self )
2002-06-01 08:34:30 -04:00
{
2006-06-18 07:34:53 -04:00
return ole_methods ( self , INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF ) ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # ole_func_methods
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Returns the array of WIN32OLE_METHOD object .
* The element of the array is property ( settable ) of WIN32OLE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* properties = excel . ole_func_methods
*
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_func_methods ( VALUE self )
2002-06-01 08:34:30 -04:00
{
2004-10-19 07:40:33 -04:00
return ole_methods ( self , INVOKE_FUNC ) ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
2004-11-06 06:42:35 -05:00
* WIN32OLE # ole_type
2010-04-22 04:04:13 -04:00
*
2004-10-30 02:25:00 -04:00
* Returns WIN32OLE_TYPE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
2004-11-06 06:42:35 -05:00
* tobj = excel . ole_type
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_type ( VALUE self )
2002-06-01 08:34:30 -04:00
{
ITypeInfo * pTypeInfo ;
HRESULT hr ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2002-06-01 08:34:30 -04:00
VALUE type = Qnil ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-06-01 08:34:30 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetTypeInfo ( pole - > pDispatch , 0 , lcid , & pTypeInfo ) ;
if ( FAILED ( hr ) ) {
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to GetTypeInfo " ) ;
2002-06-01 08:34:30 -04:00
}
2005-07-30 05:51:48 -04:00
type = ole_type_from_itypeinfo ( pTypeInfo ) ;
2002-06-01 08:34:30 -04:00
OLE_RELEASE ( pTypeInfo ) ;
2005-07-30 05:51:48 -04:00
if ( type = = Qnil ) {
rb_raise ( rb_eRuntimeError , " failed to create WIN32OLE_TYPE obj from ITypeInfo " ) ;
}
2002-06-01 08:34:30 -04:00
return type ;
}
2005-07-30 05:51:48 -04:00
/*
* call - seq :
2010-04-22 04:04:13 -04:00
* WIN32OLE # ole_typelib - > The WIN32OLE_TYPELIB object
2005-07-30 05:51:48 -04:00
*
* Returns the WIN32OLE_TYPELIB object . The object represents the
* type library which contains the WIN32OLE object .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* tlib = excel . ole_typelib
* puts tlib . name # - > ' Microsoft Excel 9.0 Object Library '
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_typelib ( VALUE self )
2005-07-30 05:51:48 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2005-07-30 05:51:48 -04:00
HRESULT hr ;
ITypeInfo * pTypeInfo ;
2007-01-29 07:41:50 -05:00
LCID lcid = cWIN32OLE_lcid ;
2005-07-30 05:51:48 -04:00
VALUE vtlib = Qnil ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2005-07-30 05:51:48 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetTypeInfo ( pole - > pDispatch ,
0 , lcid , & pTypeInfo ) ;
if ( FAILED ( hr ) ) {
ole_raise ( hr , rb_eRuntimeError , " failed to GetTypeInfo " ) ;
}
vtlib = ole_typelib_from_itypeinfo ( pTypeInfo ) ;
OLE_RELEASE ( pTypeInfo ) ;
if ( vtlib = = Qnil ) {
rb_raise ( rb_eRuntimeError , " failed to get type library info. " ) ;
}
return vtlib ;
}
2007-02-10 06:29:49 -05:00
/*
* call - seq :
* WIN32OLE # ole_query_interface ( iid ) - > WIN32OLE object
2010-04-22 04:04:13 -04:00
*
2007-02-10 06:29:49 -05:00
* Returns WIN32OLE object for a specific dispatch or dual
* interface specified by iid .
*
* ie = WIN32OLE . new ( ' InternetExplorer . Application ' )
2010-04-22 04:04:13 -04:00
* ie_web_app = ie . ole_query_interface ( ' { 0002 DF05 - 0000 - 0000 - C000 - 000000000046 } ' ) # = > WIN32OLE object for dispinterface IWebBrowserApp
2007-02-10 06:29:49 -05:00
*/
static VALUE
fole_query_interface ( VALUE self , VALUE str_iid )
{
HRESULT hr ;
OLECHAR * pBuf ;
IID iid ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2007-02-10 06:29:49 -05:00
IDispatch * pDispatch ;
2008-07-23 18:01:36 -04:00
void * p ;
2010-04-22 04:04:13 -04:00
2008-06-27 19:43:57 -04:00
pBuf = ole_vstr2wc ( str_iid ) ;
2007-02-10 06:29:49 -05:00
hr = CLSIDFromString ( pBuf , & iid ) ;
SysFreeString ( pBuf ) ;
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
* regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,
compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c,
ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb,
ext/openssl/ossl_bn.c, numeric.c, vm.c,
benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal"
for non law violation context.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 21:31:11 -05:00
" invalid iid: `%s' " ,
2007-02-10 06:29:49 -05:00
StringValuePtr ( str_iid ) ) ;
}
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2007-02-10 06:29:49 -05:00
if ( ! pole - > pDispatch ) {
rb_raise ( rb_eRuntimeError , " failed to get dispatch interface " ) ;
}
hr = pole - > pDispatch - > lpVtbl - > QueryInterface ( pole - > pDispatch , & iid ,
2008-07-23 18:01:36 -04:00
& p ) ;
2007-02-10 06:29:49 -05:00
if ( FAILED ( hr ) ) {
2010-04-22 04:04:13 -04:00
ole_raise ( hr , eWIN32OLERuntimeError ,
" failed to get interface `%s' " ,
2007-02-10 06:29:49 -05:00
StringValuePtr ( str_iid ) ) ;
}
2008-07-23 18:01:36 -04:00
pDispatch = p ;
2007-02-10 06:29:49 -05:00
return create_win32ole_object ( cWIN32OLE , pDispatch , 0 , 0 ) ;
}
2008-07-04 21:01:01 -04:00
/*
* call - seq :
* WIN32OLE # ole_respond_to ? ( method ) - > true or false
2010-04-22 04:04:13 -04:00
*
2008-07-04 21:01:01 -04:00
* Returns true when OLE object has OLE method , otherwise returns false .
*
* ie = WIN32OLE . new ( ' InternetExplorer . Application ' )
* ie . ole_respond_to ? ( " gohome " ) = > true
*/
static VALUE
fole_respond_to ( VALUE self , VALUE method )
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2008-07-04 21:01:01 -04:00
BSTR wcmdname ;
DISPID DispID ;
HRESULT hr ;
2014-08-02 21:56:01 -04:00
if ( ! RB_TYPE_P ( method , T_STRING ) & & ! RB_TYPE_P ( method , T_SYMBOL ) ) {
2014-08-15 07:36:12 -04:00
rb_raise ( rb_eTypeError , " wrong argument type (expected String or Symbol) " ) ;
2008-08-03 06:43:44 -04:00
}
2014-08-02 21:56:01 -04:00
if ( RB_TYPE_P ( method , T_SYMBOL ) ) {
2015-04-13 23:36:40 -04:00
method = rb_sym2str ( method ) ;
2008-08-03 06:43:44 -04:00
}
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2008-07-04 21:01:01 -04:00
wcmdname = ole_vstr2wc ( method ) ;
hr = pole - > pDispatch - > lpVtbl - > GetIDsOfNames ( pole - > pDispatch , & IID_NULL ,
& wcmdname , 1 , cWIN32OLE_lcid , & DispID ) ;
SysFreeString ( wcmdname ) ;
return SUCCEEDED ( hr ) ? Qtrue : Qfalse ;
}
2014-08-08 11:37:32 -04:00
HRESULT
2006-04-30 09:11:12 -04:00
ole_docinfo_from_type ( ITypeInfo * pTypeInfo , BSTR * name , BSTR * helpstr , DWORD * helpcontext , BSTR * helpfile )
2002-06-01 08:34:30 -04:00
{
HRESULT hr ;
ITypeLib * pTypeLib ;
UINT i ;
hr = pTypeInfo - > lpVtbl - > GetContainingTypeLib ( pTypeInfo , & pTypeLib , & i ) ;
if ( FAILED ( hr ) ) {
return hr ;
}
2010-04-22 04:04:13 -04:00
2002-06-01 08:34:30 -04:00
hr = pTypeLib - > lpVtbl - > GetDocumentation ( pTypeLib , i ,
2010-04-22 04:04:13 -04:00
name , helpstr ,
2002-06-01 08:34:30 -04:00
helpcontext , helpfile ) ;
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pTypeLib ) ;
return hr ;
}
OLE_RELEASE ( pTypeLib ) ;
return hr ;
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_usertype2val ( ITypeInfo * pTypeInfo , TYPEDESC * pTypeDesc , VALUE typedetails )
2002-06-01 08:34:30 -04:00
{
HRESULT hr ;
BSTR bstr ;
ITypeInfo * pRefTypeInfo ;
VALUE type = Qnil ;
2010-04-22 04:04:13 -04:00
hr = pTypeInfo - > lpVtbl - > GetRefTypeInfo ( pTypeInfo ,
2002-06-01 08:34:30 -04:00
V_UNION1 ( pTypeDesc , hreftype ) ,
2004-02-15 01:53:15 -05:00
& pRefTypeInfo ) ;
2002-06-01 08:34:30 -04:00
if ( FAILED ( hr ) )
return Qnil ;
hr = ole_docinfo_from_type ( pRefTypeInfo , & bstr , NULL , NULL , NULL ) ;
if ( FAILED ( hr ) ) {
OLE_RELEASE ( pRefTypeInfo ) ;
return Qnil ;
}
OLE_RELEASE ( pRefTypeInfo ) ;
type = WC2VSTR ( bstr ) ;
if ( typedetails ! = Qnil )
rb_ary_push ( typedetails , type ) ;
return type ;
}
static VALUE
2006-04-30 09:11:12 -04:00
ole_ptrtype2val ( ITypeInfo * pTypeInfo , TYPEDESC * pTypeDesc , VALUE typedetails )
2010-04-22 04:04:13 -04:00
{
2002-06-01 08:34:30 -04:00
TYPEDESC * p = pTypeDesc ;
VALUE type = rb_str_new2 ( " " ) ;
2007-02-11 08:45:57 -05:00
if ( p - > vt = = VT_PTR | | p - > vt = = VT_SAFEARRAY ) {
2004-02-15 01:53:15 -05:00
p = V_UNION1 ( p , lptdesc ) ;
2007-02-11 08:45:57 -05:00
type = ole_typedesc2val ( pTypeInfo , p , typedetails ) ;
2002-06-01 08:34:30 -04:00
}
return type ;
}
2014-08-08 11:37:32 -04:00
VALUE
2006-04-30 09:11:12 -04:00
ole_typedesc2val ( ITypeInfo * pTypeInfo , TYPEDESC * pTypeDesc , VALUE typedetails )
2002-06-01 08:34:30 -04:00
{
VALUE str ;
2007-02-11 04:53:10 -05:00
VALUE typestr = Qnil ;
2002-06-01 08:34:30 -04:00
switch ( pTypeDesc - > vt ) {
case VT_I2 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " I2 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_I4 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " I4 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_R4 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " R4 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_R8 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " R8 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_CY :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " CY " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_DATE :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " DATE " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_BSTR :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " BSTR " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_BOOL :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " BOOL " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_VARIANT :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " VARIANT " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_DECIMAL :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " DECIMAL " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_I1 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " I1 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UI1 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UI1 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UI2 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UI2 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UI4 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UI4 " ) ;
break ;
2007-03-02 07:35:02 -05:00
# if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__)
2002-06-01 08:34:30 -04:00
case VT_I8 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " I8 " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UI8 :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UI8 " ) ;
break ;
2007-03-02 07:35:02 -05:00
# endif
2002-06-01 08:34:30 -04:00
case VT_INT :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " INT " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_UINT :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UINT " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_VOID :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " VOID " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_HRESULT :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " HRESULT " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_PTR :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " PTR " ) ;
2002-06-01 08:34:30 -04:00
if ( typedetails ! = Qnil )
2007-02-11 04:53:10 -05:00
rb_ary_push ( typedetails , typestr ) ;
2002-06-01 08:34:30 -04:00
return ole_ptrtype2val ( pTypeInfo , pTypeDesc , typedetails ) ;
case VT_SAFEARRAY :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " SAFEARRAY " ) ;
2002-06-01 08:34:30 -04:00
if ( typedetails ! = Qnil )
2007-02-11 04:53:10 -05:00
rb_ary_push ( typedetails , typestr ) ;
2002-06-01 08:34:30 -04:00
return ole_ptrtype2val ( pTypeInfo , pTypeDesc , typedetails ) ;
case VT_CARRAY :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " CARRAY " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_USERDEFINED :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " USERDEFINED " ) ;
2010-04-22 04:04:13 -04:00
if ( typedetails ! = Qnil )
2007-02-11 04:53:10 -05:00
rb_ary_push ( typedetails , typestr ) ;
2002-06-01 08:34:30 -04:00
str = ole_usertype2val ( pTypeInfo , pTypeDesc , typedetails ) ;
2004-02-15 01:53:15 -05:00
if ( str ! = Qnil ) {
return str ;
}
2007-02-11 04:53:10 -05:00
return typestr ;
2002-06-01 08:34:30 -04:00
case VT_UNKNOWN :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " UNKNOWN " ) ;
break ;
2002-06-01 08:34:30 -04:00
case VT_DISPATCH :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " DISPATCH " ) ;
break ;
2004-11-04 07:12:59 -05:00
case VT_ERROR :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " ERROR " ) ;
break ;
2004-11-04 07:12:59 -05:00
case VT_LPWSTR :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " LPWSTR " ) ;
break ;
2004-11-04 07:12:59 -05:00
case VT_LPSTR :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " LPSTR " ) ;
break ;
2014-02-01 01:16:42 -05:00
case VT_RECORD :
typestr = rb_str_new2 ( " RECORD " ) ;
break ;
2002-06-01 08:34:30 -04:00
default :
2007-02-11 04:53:10 -05:00
typestr = rb_str_new2 ( " Unknown Type " ) ;
rb_str_concat ( typestr , rb_fix2str ( INT2FIX ( pTypeDesc - > vt ) , 10 ) ) ;
break ;
2002-06-01 08:34:30 -04:00
}
2007-02-11 04:53:10 -05:00
if ( typedetails ! = Qnil )
rb_ary_push ( typedetails , typestr ) ;
return typestr ;
2002-06-01 08:34:30 -04:00
}
/*
2004-10-30 02:25:00 -04:00
* call - seq :
* WIN32OLE # ole_method_help ( method )
2010-04-22 04:04:13 -04:00
*
* Returns WIN32OLE_METHOD object corresponding with method
2004-10-30 02:25:00 -04:00
* specified by 1 st argument .
*
* excel = WIN32OLE . new ( ' Excel . Application ' )
* method = excel . ole_method_help ( ' Quit ' )
*
2002-06-01 08:34:30 -04:00
*/
static VALUE
2006-04-30 09:11:12 -04:00
fole_method_help ( VALUE self , VALUE cmdname )
2002-06-01 08:34:30 -04:00
{
ITypeInfo * pTypeInfo ;
HRESULT hr ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2014-08-12 10:21:22 -04:00
VALUE obj ;
2002-06-01 08:34:30 -04:00
2009-08-28 07:38:57 -04:00
SafeStringValue ( cmdname ) ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2002-08-10 08:19:16 -04:00
hr = typeinfo_from_ole ( pole , & pTypeInfo ) ;
if ( FAILED ( hr ) )
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
ole_raise ( hr , rb_eRuntimeError , " failed to get ITypeInfo " ) ;
2014-08-11 17:20:10 -04:00
2014-08-12 10:21:22 -04:00
obj = create_win32ole_method ( pTypeInfo , cmdname ) ;
2014-08-11 17:20:10 -04:00
2002-06-01 08:34:30 -04:00
OLE_RELEASE ( pTypeInfo ) ;
if ( obj = = Qnil )
2007-01-27 18:46:27 -05:00
rb_raise ( eWIN32OLERuntimeError , " not found %s " ,
2004-02-15 01:53:15 -05:00
StringValuePtr ( cmdname ) ) ;
2002-06-01 08:34:30 -04:00
return obj ;
}
2007-03-16 09:24:06 -04:00
/*
* call - seq :
* WIN32OLE # ole_activex_initialize ( ) - > Qnil
*
2010-04-22 04:04:13 -04:00
* Initialize WIN32OLE object ( ActiveX Control ) by calling
2007-03-16 09:24:06 -04:00
* IPersistMemory : : InitNew .
*
2010-04-22 04:04:13 -04:00
* Before calling OLE method , some kind of the ActiveX controls
* created with MFC should be initialized by calling
2007-03-16 09:24:06 -04:00
* IPersistXXX : : InitNew .
*
2008-07-18 20:35:38 -04:00
* If and only if you received the exception " HRESULT error code:
2007-03-16 09:24:06 -04:00
* 0x8000ffff catastrophic failure " , try this method before
* invoking any ole_method .
*
* obj = WIN32OLE . new ( " ProgID_or_GUID_of_ActiveX_Control " )
* obj . ole_activex_initialize
* obj . method ( . . . )
2010-04-22 04:04:13 -04:00
*
*/
2007-03-16 09:24:06 -04:00
static VALUE
2010-04-22 04:04:13 -04:00
fole_activex_initialize ( VALUE self )
2007-03-16 09:24:06 -04:00
{
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2007-03-16 09:24:06 -04:00
IPersistMemory * pPersistMemory ;
2008-07-23 18:01:36 -04:00
void * p ;
2007-03-16 09:24:06 -04:00
HRESULT hr = S_OK ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( self ) ;
2007-03-16 09:24:06 -04:00
2008-07-23 18:01:36 -04:00
hr = pole - > pDispatch - > lpVtbl - > QueryInterface ( pole - > pDispatch , & IID_IPersistMemory , & p ) ;
pPersistMemory = p ;
2007-03-16 09:24:06 -04:00
if ( SUCCEEDED ( hr ) ) {
hr = pPersistMemory - > lpVtbl - > InitNew ( pPersistMemory ) ;
OLE_RELEASE ( pPersistMemory ) ;
if ( SUCCEEDED ( hr ) ) {
return Qnil ;
}
}
if ( FAILED ( hr ) ) {
ole_raise ( hr , eWIN32OLERuntimeError , " fail to initialize ActiveX control " ) ;
}
return Qnil ;
}
2014-08-13 11:28:26 -04:00
HRESULT
2014-07-24 09:51:22 -04:00
typelib_from_val ( VALUE obj , ITypeLib * * pTypeLib )
{
LCID lcid = cWIN32OLE_lcid ;
HRESULT hr ;
2014-12-01 06:03:13 -05:00
struct oledata * pole = NULL ;
2014-07-24 09:51:22 -04:00
unsigned int index ;
ITypeInfo * pTypeInfo ;
2014-12-01 06:03:13 -05:00
pole = oledata_get_struct ( obj ) ;
2014-07-24 09:51:22 -04:00
hr = pole - > pDispatch - > lpVtbl - > GetTypeInfo ( pole - > pDispatch ,
0 , lcid , & pTypeInfo ) ;
if ( FAILED ( hr ) ) {
return hr ;
}
hr = pTypeInfo - > lpVtbl - > GetContainingTypeLib ( pTypeInfo , pTypeLib , & index ) ;
OLE_RELEASE ( pTypeInfo ) ;
return hr ;
}
2014-12-02 07:34:52 -05:00
static void
com_hash_free ( void * ptr )
{
st_table * tbl = ptr ;
st_free_table ( tbl ) ;
}
static void
com_hash_mark ( void * ptr )
{
st_table * tbl = ptr ;
rb_mark_hash ( tbl ) ;
}
static size_t
com_hash_size ( const void * ptr )
{
const st_table * tbl = ptr ;
2015-12-08 20:01:17 -05:00
return st_memsize ( tbl ) ;
2014-12-02 07:34:52 -05:00
}
2002-06-01 08:34:30 -04:00
void
2013-01-17 00:06:28 -05:00
Init_win32ole ( void )
2002-06-01 08:34:30 -04:00
{
2014-08-06 05:47:39 -04:00
cWIN32OLE_lcid = LOCALE_SYSTEM_DEFAULT ;
2013-01-17 21:23:37 -05:00
g_ole_initialized_init ( ) ;
2002-06-01 08:34:30 -04:00
2004-02-15 01:53:15 -05:00
com_vtbl . QueryInterface = QueryInterface ;
com_vtbl . AddRef = AddRef ;
com_vtbl . Release = Release ;
com_vtbl . GetTypeInfoCount = GetTypeInfoCount ;
com_vtbl . GetTypeInfo = GetTypeInfo ;
com_vtbl . GetIDsOfNames = GetIDsOfNames ;
com_vtbl . Invoke = Invoke ;
2008-07-02 11:35:04 -04:00
message_filter . QueryInterface = mf_QueryInterface ;
message_filter . AddRef = mf_AddRef ;
message_filter . Release = mf_Release ;
message_filter . HandleInComingCall = mf_HandleInComingCall ;
message_filter . RetryRejectedCall = mf_RetryRejectedCall ;
message_filter . MessagePending = mf_MessagePending ;
2010-04-22 04:04:13 -04:00
2015-05-28 02:46:17 -04:00
enc2cp_hash = TypedData_Wrap_Struct ( rb_cData , & win32ole_hash_datatype , 0 ) ;
RTYPEDDATA_DATA ( enc2cp_hash ) = st_init_numtable ( ) ;
2015-02-04 06:30:37 -05:00
rb_gc_register_mark_object ( enc2cp_hash ) ;
2015-05-28 02:46:17 -04:00
com_hash = TypedData_Wrap_Struct ( rb_cData , & win32ole_hash_datatype , 0 ) ;
RTYPEDDATA_DATA ( com_hash ) = st_init_numtable ( ) ;
* gc.c, include/ruby/ruby.h: rename rb_register_mark_object()
to rb_gc_register_mark_object().
* eval.c, vm.c: initialize vm->mark_object_ary at
Init_top_self().
* bignum.c, complex.c, encoding.c, ext/win32ole/win32ole.c,
io.c, load.c, marshal.c, rational.c, ruby.c, vm.c:
use rb_gc_register_mark_object() instead of
rb_global_variable() or rb_gc_register_address().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-15 10:59:14 -04:00
rb_gc_register_mark_object ( com_hash ) ;
2004-02-15 01:53:15 -05:00
2002-06-01 08:34:30 -04:00
cWIN32OLE = rb_define_class ( " WIN32OLE " , rb_cObject ) ;
* ext/curses/curses.c, ext/digest/digest.c, ext/dl/handle.c,
ext/dl/ptr.c, ext/dl/sym.c, ext/gdbm/gdbm.c, ext/iconv/iconv.c,
ext/stringio/stringio.c, ext/strscan/strscan.c,
ext/tcltklib/tcltklib.c, ext/win32ole/win32ole.c:
use rb_define_alloc_func().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-12-20 06:23:40 -05:00
rb_define_alloc_func ( cWIN32OLE , fole_s_allocate ) ;
2002-06-01 08:34:30 -04:00
rb_define_method ( cWIN32OLE , " initialize " , fole_initialize , - 1 ) ;
rb_define_singleton_method ( cWIN32OLE , " connect " , fole_s_connect , - 1 ) ;
rb_define_singleton_method ( cWIN32OLE , " const_load " , fole_s_const_load , - 1 ) ;
rb_define_singleton_method ( cWIN32OLE , " ole_free " , fole_s_free , 1 ) ;
rb_define_singleton_method ( cWIN32OLE , " ole_reference_count " , fole_s_reference_count , 1 ) ;
rb_define_singleton_method ( cWIN32OLE , " ole_show_help " , fole_s_show_help , - 1 ) ;
2004-10-31 02:59:58 -05:00
rb_define_singleton_method ( cWIN32OLE , " codepage " , fole_s_get_code_page , 0 ) ;
rb_define_singleton_method ( cWIN32OLE , " codepage= " , fole_s_set_code_page , 1 ) ;
2007-01-29 07:41:50 -05:00
rb_define_singleton_method ( cWIN32OLE , " locale " , fole_s_get_locale , 0 ) ;
rb_define_singleton_method ( cWIN32OLE , " locale= " , fole_s_set_locale , 1 ) ;
2006-02-11 08:00:46 -05:00
rb_define_singleton_method ( cWIN32OLE , " create_guid " , fole_s_create_guid , 0 ) ;
2010-01-23 06:02:17 -05:00
rb_define_singleton_method ( cWIN32OLE , " ole_initialize " , fole_s_ole_initialize , 0 ) ;
rb_define_singleton_method ( cWIN32OLE , " ole_uninitialize " , fole_s_ole_uninitialize , 0 ) ;
2002-06-01 08:34:30 -04:00
rb_define_method ( cWIN32OLE , " invoke " , fole_invoke , - 1 ) ;
2006-03-29 09:12:49 -05:00
rb_define_method ( cWIN32OLE , " [] " , fole_getproperty_with_bracket , - 1 ) ;
2002-06-01 08:34:30 -04:00
rb_define_method ( cWIN32OLE , " _invoke " , fole_invoke2 , 3 ) ;
rb_define_method ( cWIN32OLE , " _getproperty " , fole_getproperty2 , 3 ) ;
rb_define_method ( cWIN32OLE , " _setproperty " , fole_setproperty2 , 3 ) ;
/* support propput method that takes an argument */
2010-04-22 04:04:13 -04:00
rb_define_method ( cWIN32OLE , " []= " , fole_setproperty_with_bracket , - 1 ) ;
2002-06-01 08:34:30 -04:00
2002-08-10 08:19:16 -04:00
rb_define_method ( cWIN32OLE , " ole_free " , fole_free , 0 ) ;
2002-06-01 08:34:30 -04:00
rb_define_method ( cWIN32OLE , " each " , fole_each , 0 ) ;
rb_define_method ( cWIN32OLE , " method_missing " , fole_missing , - 1 ) ;
/* support setproperty method much like Perl ;-) */
rb_define_method ( cWIN32OLE , " setproperty " , fole_setproperty , - 1 ) ;
rb_define_method ( cWIN32OLE , " ole_methods " , fole_methods , 0 ) ;
rb_define_method ( cWIN32OLE , " ole_get_methods " , fole_get_methods , 0 ) ;
rb_define_method ( cWIN32OLE , " ole_put_methods " , fole_put_methods , 0 ) ;
rb_define_method ( cWIN32OLE , " ole_func_methods " , fole_func_methods , 0 ) ;
rb_define_method ( cWIN32OLE , " ole_method " , fole_method_help , 1 ) ;
rb_define_alias ( cWIN32OLE , " ole_method_help " , " ole_method " ) ;
2007-03-16 09:24:06 -04:00
rb_define_method ( cWIN32OLE , " ole_activex_initialize " , fole_activex_initialize , 0 ) ;
2004-11-06 06:42:35 -05:00
rb_define_method ( cWIN32OLE , " ole_type " , fole_type , 0 ) ;
rb_define_alias ( cWIN32OLE , " ole_obj_help " , " ole_type " ) ;
2004-10-30 02:25:00 -04:00
rb_define_method ( cWIN32OLE , " ole_typelib " , fole_typelib , 0 ) ;
2007-02-10 06:29:49 -05:00
rb_define_method ( cWIN32OLE , " ole_query_interface " , fole_query_interface , 1 ) ;
2008-07-04 21:01:01 -04:00
rb_define_method ( cWIN32OLE , " ole_respond_to? " , fole_respond_to , 1 ) ;
2002-06-01 08:34:30 -04:00
2014-07-14 06:17:40 -04:00
/* Constants definition */
/*
* Version string of WIN32OLE .
*/
2002-06-01 08:34:30 -04:00
rb_define_const ( cWIN32OLE , " VERSION " , rb_str_new2 ( WIN32OLE_VERSION ) ) ;
2014-07-14 06:17:40 -04:00
/*
* After invoking OLE methods with reference arguments , you can access
* the value of arguments by using ARGV .
*
* If the method of OLE ( COM ) server written by C # . NET is following :
*
* void calcsum ( int a , int b , out int c ) {
* c = a + b ;
* }
*
* then , the Ruby OLE ( COM ) client script to retrieve the value of
* argument c after invoking calcsum method is following :
*
* a = 10
* b = 20
* c = 0
* comserver . calcsum ( a , b , c )
* p c # = > 0
* p WIN32OLE : : ARGV # = > [ 10 , 20 , 30 ]
*
* You can use WIN32OLE_VARIANT object to retrieve the value of reference
2015-06-03 22:53:11 -04:00
* arguments instead of referring WIN32OLE : : ARGV .
2014-07-14 06:17:40 -04:00
*
*/
2002-06-01 08:34:30 -04:00
rb_define_const ( cWIN32OLE , " ARGV " , rb_ary_new ( ) ) ;
2007-01-29 07:41:50 -05:00
2014-07-14 06:17:40 -04:00
/*
* 0 : ANSI code page . See WIN32OLE . codepage and WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_ACP " , INT2FIX ( CP_ACP ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 1 : OEM code page . See WIN32OLE . codepage and WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_OEMCP " , INT2FIX ( CP_OEMCP ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 2
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_MACCP " , INT2FIX ( CP_MACCP ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 3 : current thread ANSI code page . See WIN32OLE . codepage and
* WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_THREAD_ACP " , INT2FIX ( CP_THREAD_ACP ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 42 : symbol code page . See WIN32OLE . codepage and WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_SYMBOL " , INT2FIX ( CP_SYMBOL ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 65000 : UTF - 7 code page . See WIN32OLE . codepage and WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_UTF7 " , INT2FIX ( CP_UTF7 ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 65001 : UTF - 8 code page . See WIN32OLE . codepage and WIN32OLE . codepage = .
*/
2007-01-19 03:22:45 -05:00
rb_define_const ( cWIN32OLE , " CP_UTF8 " , INT2FIX ( CP_UTF8 ) ) ;
2002-06-01 08:34:30 -04:00
2014-07-14 06:17:40 -04:00
/*
* 0x0800 : default locale for the operating system . See WIN32OLE . locale
* and WIN32OLE . locale = .
*/
2007-01-29 07:41:50 -05:00
rb_define_const ( cWIN32OLE , " LOCALE_SYSTEM_DEFAULT " , INT2FIX ( LOCALE_SYSTEM_DEFAULT ) ) ;
2014-07-14 06:17:40 -04:00
/*
* 0x0400 : default locale for the user or process . See WIN32OLE . locale
* and WIN32OLE . locale = .
*/
2007-01-29 07:41:50 -05:00
rb_define_const ( cWIN32OLE , " LOCALE_USER_DEFAULT " , INT2FIX ( LOCALE_USER_DEFAULT ) ) ;
2014-08-02 10:55:36 -04:00
Init_win32ole_variant_m ( ) ;
2014-08-06 08:00:09 -04:00
Init_win32ole_typelib ( ) ;
2014-08-08 11:37:32 -04:00
Init_win32ole_type ( ) ;
2014-08-11 07:50:17 -04:00
Init_win32ole_variable ( ) ;
2014-08-11 17:20:10 -04:00
Init_win32ole_method ( ) ;
2014-08-12 11:09:29 -04:00
Init_win32ole_param ( ) ;
2014-08-15 07:36:12 -04:00
Init_win32ole_event ( ) ;
2014-08-13 08:46:23 -04:00
Init_win32ole_variant ( ) ;
2014-08-13 11:28:26 -04:00
Init_win32ole_record ( ) ;
2014-08-06 05:47:39 -04:00
Init_win32ole_error ( ) ;
2006-03-29 09:12:49 -05:00
2008-02-15 06:36:24 -05:00
ole_init_cp ( ) ;
2002-06-01 08:34:30 -04:00
}