From 4e7801a1aa4d275ec2cf8e4ff3f5411c7ad52bb0 Mon Sep 17 00:00:00 2001 From: suke Date: Sat, 2 Aug 2014 14:55:36 +0000 Subject: * ext/win32ole/win32ole.c: separate WIN32OLE::VARIANT src file from win32ole.c * ext/win32ole/win32ole.h: ditto. * ext/win32ole/win32ole_variant_m.c: ditto. * ext/win32ole/win32ole_variant_m.h: ditto. * ext/win32ole/depend: ditto. * ext/.document: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/win32ole/depend | 4 +- ext/win32ole/win32ole.c | 227 +------------------------------------- ext/win32ole/win32ole.h | 90 +++++++++++++++ ext/win32ole/win32ole_variant_m.c | 148 +++++++++++++++++++++++++ ext/win32ole/win32ole_variant_m.h | 7 ++ 5 files changed, 250 insertions(+), 226 deletions(-) create mode 100644 ext/win32ole/win32ole.h create mode 100644 ext/win32ole/win32ole_variant_m.c create mode 100644 ext/win32ole/win32ole_variant_m.h (limited to 'ext/win32ole') diff --git a/ext/win32ole/depend b/ext/win32ole/depend index 3b1d7e9a97..5853c00f9d 100644 --- a/ext/win32ole/depend +++ b/ext/win32ole/depend @@ -1 +1,3 @@ -win32ole.o : win32ole.c $(hdrdir)/ruby.h $(hdrdir)/config.h $(hdrdir)/defines.h +WIN32OLE_HEADERS = $(HDRS) $(ruby_headers) +win32ole.o : win32ole.c $(WIN32OLE_HEADERS) +win32ole_variant_m.o : win32ole_variant_m.c $(WIN32OLE_HEADERS) diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 5c54ed8db5..219e173d76 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -15,87 +15,7 @@ modified for win32ole (ruby) by Masaki.Suketa */ -#include "ruby/ruby.h" -#include "ruby/st.h" -#include "ruby/encoding.h" - -#define GNUC_OLDER_3_4_4 \ - ((__GNUC__ < 3) || \ - ((__GNUC__ <= 3) && (__GNUC_MINOR__ < 4)) || \ - ((__GNUC__ <= 3) && (__GNUC_MINOR__ <= 4) && (__GNUC_PATCHLEVEL__ <= 4))) - -#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) -#ifndef NONAMELESSUNION -#define NONAMELESSUNION 1 -#endif -#endif - -#include - -#include -#include -#include -#include -#if defined(HAVE_TYPE_IMULTILANGUAGE2) || defined(HAVE_TYPE_IMULTILANGUAGE) -#include -#endif -#include -#include -#ifdef HAVE_STDARG_PROTOTYPES -#include -#define va_init_list(a,b) va_start(a,b) -#else -#include -#define va_init_list(a,b) va_start(a) -#endif -#include - -#define DOUT fprintf(stderr,"[%d]\n",__LINE__) -#define DOUTS(x) fprintf(stderr,"[%d]:" #x "=%s\n",__LINE__,x) -#define DOUTMSG(x) fprintf(stderr, "[%d]:" #x "\n",__LINE__) -#define DOUTI(x) fprintf(stderr, "[%ld]:" #x "=%d\n",__LINE__,x) -#define DOUTD(x) fprintf(stderr, "[%d]:" #x "=%f\n",__LINE__,x) - -#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) -#define V_UNION1(X, Y) ((X)->u.Y) -#else -#define V_UNION1(X, Y) ((X)->Y) -#endif - -#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) -#undef V_UNION -#define V_UNION(X,Y) ((X)->n1.n2.n3.Y) - -#undef V_VT -#define V_VT(X) ((X)->n1.n2.vt) - -#undef V_BOOL -#define V_BOOL(X) V_UNION(X,boolVal) -#endif - -#ifndef V_I1REF -#define V_I1REF(X) V_UNION(X, pcVal) -#endif - -#ifndef V_UI2REF -#define V_UI2REF(X) V_UNION(X, puiVal) -#endif - -#ifndef V_INT -#define V_INT(X) V_UNION(X, intVal) -#endif - -#ifndef V_INTREF -#define V_INTREF(X) V_UNION(X, pintVal) -#endif - -#ifndef V_UINT -#define V_UINT(X) V_UNION(X, uintVal) -#endif - -#ifndef V_UINTREF -#define V_UINTREF(X) V_UNION(X, puintVal) -#endif +#include "win32ole.h" /* * unfortunately IID_IMultiLanguage2 is not included in any libXXX.a @@ -209,7 +129,6 @@ VALUE cWIN32OLE_PARAM; VALUE cWIN32OLE_EVENT; VALUE cWIN32OLE_VARIANT; VALUE eWIN32OLERuntimeError; -VALUE mWIN32OLE_VARIANT; VALUE cWIN32OLE_PROPERTY; VALUE cWIN32OLE_RECORD; @@ -9896,149 +9815,7 @@ Init_win32ole(void) */ rb_define_const(cWIN32OLE, "LOCALE_USER_DEFAULT", INT2FIX(LOCALE_USER_DEFAULT)); - /* - * Document-module: WIN32OLE::VARIANT - * - * The WIN32OLE::VARIANT module includes constants of VARIANT type constants. - * The constants is used when creating WIN32OLE_VARIANT object. - * - * obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4) - * obj.value # => 2000.0 - * - */ - mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT"); - - /* - * represents VT_EMPTY type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_EMPTY", INT2FIX(VT_EMPTY)); - - /* - * represents VT_NULL type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_NULL", INT2FIX(VT_NULL)); - - /* - * represents VT_I2 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2)); - - /* - * represents VT_I4 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4)); - - /* - * represents VT_R4 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4)); - - /* - * represents VT_R8 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_R8", INT2FIX(VT_R8)); - - /* - * represents VT_CY type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_CY", INT2FIX(VT_CY)); - - /* - * represents VT_DATE type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", INT2FIX(VT_DATE)); - - /* - * represents VT_BSTR type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", INT2FIX(VT_BSTR)); - - /* - * represents VT_USERDEFINED type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", INT2FIX(VT_USERDEFINED)); - - /* - * represents VT_PTR type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", INT2FIX(VT_PTR)); - - /* - * represents VT_DISPATCH type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", INT2FIX(VT_DISPATCH)); - - /* - * represents VT_ERROR type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", INT2FIX(VT_ERROR)); - - /* - * represents VT_BOOL type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", INT2FIX(VT_BOOL)); - - /* - * represents VT_VARIANT type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", INT2FIX(VT_VARIANT)); - - /* - * represents VT_UNKNOWN type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", INT2FIX(VT_UNKNOWN)); - - /* - * represents VT_I1 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_I1", INT2FIX(VT_I1)); - - /* - * represents VT_UI1 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1)); - - /* - * represents VT_UI2 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2)); - - /* - * represents VT_UI4 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4)); - -#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) - /* - * represents VT_I8 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_I8", INT2FIX(VT_I8)); - - /* - * represents VT_UI8 type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UI8", INT2FIX(VT_UI8)); -#endif - - /* - * represents VT_INT type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT)); - - /* - * represents VT_UINT type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT)); - - /* - * represents VT_ARRAY type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY)); - - /* - * represents VT_BYREF type constant. - */ - rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF)); + Init_win32ole_variant_m(); cWIN32OLE_TYPELIB = rb_define_class("WIN32OLE_TYPELIB", rb_cObject); rb_define_singleton_method(cWIN32OLE_TYPELIB, "typelibs", foletypelib_s_typelibs, 0); diff --git a/ext/win32ole/win32ole.h b/ext/win32ole/win32ole.h new file mode 100644 index 0000000000..8e34f69c18 --- /dev/null +++ b/ext/win32ole/win32ole.h @@ -0,0 +1,90 @@ +#ifndef WIN32OLE_H +#define WIN32OLE_H 1 +#include "ruby/ruby.h" +#include "ruby/st.h" +#include "ruby/encoding.h" + +#define GNUC_OLDER_3_4_4 \ + ((__GNUC__ < 3) || \ + ((__GNUC__ <= 3) && (__GNUC_MINOR__ < 4)) || \ + ((__GNUC__ <= 3) && (__GNUC_MINOR__ <= 4) && (__GNUC_PATCHLEVEL__ <= 4))) + +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) +#ifndef NONAMELESSUNION +#define NONAMELESSUNION 1 +#endif +#endif + +#include + +#include +#include +#include +#include +#if defined(HAVE_TYPE_IMULTILANGUAGE2) || defined(HAVE_TYPE_IMULTILANGUAGE) +#include +#endif +#include +#include +#ifdef HAVE_STDARG_PROTOTYPES +#include +#define va_init_list(a,b) va_start(a,b) +#else +#include +#define va_init_list(a,b) va_start(a) +#endif +#include + +#define DOUT fprintf(stderr,"[%d]\n",__LINE__) +#define DOUTS(x) fprintf(stderr,"[%d]:" #x "=%s\n",__LINE__,x) +#define DOUTMSG(x) fprintf(stderr, "[%d]:" #x "\n",__LINE__) +#define DOUTI(x) fprintf(stderr, "[%ld]:" #x "=%d\n",__LINE__,x) +#define DOUTD(x) fprintf(stderr, "[%d]:" #x "=%f\n",__LINE__,x) + +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) +#define V_UNION1(X, Y) ((X)->u.Y) +#else +#define V_UNION1(X, Y) ((X)->Y) +#endif + +#if (defined(__GNUC__)) && (GNUC_OLDER_3_4_4) +#undef V_UNION +#define V_UNION(X,Y) ((X)->n1.n2.n3.Y) + +#undef V_VT +#define V_VT(X) ((X)->n1.n2.vt) + +#undef V_BOOL +#define V_BOOL(X) V_UNION(X,boolVal) +#endif + +#ifndef V_I1REF +#define V_I1REF(X) V_UNION(X, pcVal) +#endif + +#ifndef V_UI2REF +#define V_UI2REF(X) V_UNION(X, puiVal) +#endif + +#ifndef V_INT +#define V_INT(X) V_UNION(X, intVal) +#endif + +#ifndef V_INTREF +#define V_INTREF(X) V_UNION(X, pintVal) +#endif + +#ifndef V_UINT +#define V_UINT(X) V_UNION(X, uintVal) +#endif + +#ifndef V_UINTREF +#define V_UINTREF(X) V_UNION(X, puintVal) +#endif + + +VALUE cWIN32OLE; + +#include "win32ole_variant_m.h" + +#endif diff --git a/ext/win32ole/win32ole_variant_m.c b/ext/win32ole/win32ole_variant_m.c new file mode 100644 index 0000000000..ff05c1d11b --- /dev/null +++ b/ext/win32ole/win32ole_variant_m.c @@ -0,0 +1,148 @@ +#include "win32ole.h" + +void Init_win32ole_variant_m() { + /* + * Document-module: WIN32OLE::VARIANT + * + * The WIN32OLE::VARIANT module includes constants of VARIANT type constants. + * The constants is used when creating WIN32OLE_VARIANT object. + * + * obj = WIN32OLE_VARIANT.new("2e3", WIN32OLE::VARIANT::VT_R4) + * obj.value # => 2000.0 + * + */ + mWIN32OLE_VARIANT = rb_define_module_under(cWIN32OLE, "VARIANT"); + + /* + * represents VT_EMPTY type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_EMPTY", INT2FIX(VT_EMPTY)); + + /* + * represents VT_NULL type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_NULL", INT2FIX(VT_NULL)); + + /* + * represents VT_I2 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_I2", INT2FIX(VT_I2)); + + /* + * represents VT_I4 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_I4", INT2FIX(VT_I4)); + + /* + * represents VT_R4 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_R4", INT2FIX(VT_R4)); + + /* + * represents VT_R8 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_R8", INT2FIX(VT_R8)); + + /* + * represents VT_CY type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_CY", INT2FIX(VT_CY)); + + /* + * represents VT_DATE type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_DATE", INT2FIX(VT_DATE)); + + /* + * represents VT_BSTR type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_BSTR", INT2FIX(VT_BSTR)); + + /* + * represents VT_USERDEFINED type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_USERDEFINED", INT2FIX(VT_USERDEFINED)); + + /* + * represents VT_PTR type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_PTR", INT2FIX(VT_PTR)); + + /* + * represents VT_DISPATCH type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_DISPATCH", INT2FIX(VT_DISPATCH)); + + /* + * represents VT_ERROR type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_ERROR", INT2FIX(VT_ERROR)); + + /* + * represents VT_BOOL type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_BOOL", INT2FIX(VT_BOOL)); + + /* + * represents VT_VARIANT type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_VARIANT", INT2FIX(VT_VARIANT)); + + /* + * represents VT_UNKNOWN type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UNKNOWN", INT2FIX(VT_UNKNOWN)); + + /* + * represents VT_I1 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_I1", INT2FIX(VT_I1)); + + /* + * represents VT_UI1 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UI1", INT2FIX(VT_UI1)); + + /* + * represents VT_UI2 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UI2", INT2FIX(VT_UI2)); + + /* + * represents VT_UI4 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UI4", INT2FIX(VT_UI4)); + +#if (_MSC_VER >= 1300) || defined(__CYGWIN__) || defined(__MINGW32__) + /* + * represents VT_I8 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_I8", INT2FIX(VT_I8)); + + /* + * represents VT_UI8 type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UI8", INT2FIX(VT_UI8)); +#endif + + /* + * represents VT_INT type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_INT", INT2FIX(VT_INT)); + + /* + * represents VT_UINT type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_UINT", INT2FIX(VT_UINT)); + + /* + * represents VT_ARRAY type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_ARRAY", INT2FIX(VT_ARRAY)); + + /* + * represents VT_BYREF type constant. + */ + rb_define_const(mWIN32OLE_VARIANT, "VT_BYREF", INT2FIX(VT_BYREF)); + +} diff --git a/ext/win32ole/win32ole_variant_m.h b/ext/win32ole/win32ole_variant_m.h new file mode 100644 index 0000000000..56dabc1276 --- /dev/null +++ b/ext/win32ole/win32ole_variant_m.h @@ -0,0 +1,7 @@ +#ifndef WIN32OLE_VARIANT_M_H +#define WIN32OLE_VARIANT_M_H 1 + +VALUE mWIN32OLE_VARIANT; +void Init_win32ole_variant_m(); + +#endif -- cgit v1.2.3