[ruby/win32ole] Deprecate old constants in toplevel

https://github.com/ruby/win32ole/commit/eaa1507262
This commit is contained in:
Nobuyoshi Nakada 2024-12-12 23:29:14 +09:00 committed by git
parent 20b62ac063
commit 776ec52148
21 changed files with 15 additions and 40 deletions

View File

@ -32,6 +32,7 @@ def create_win32ole_makefile
spec or 'no'
end
$defs << "-DRB_THREAD_SPECIFIC=#{spec}" if spec
have_func(%[rb_deprecate_constant(Qnil, "")])
create_makefile("win32ole")
end
end

View File

@ -94,6 +94,10 @@
#define NUM2UI8 RB_NUM2UINT
#endif
#ifndef HAVE_RB_DEPRECATE_CONSTANT
# define rb_deprecate_constant(mod, name) (void)0
#endif
#define OLE_ADDREF(X) (X) ? ((X)->lpVtbl->AddRef(X)) : 0
#define OLE_RELEASE(X) (X) ? ((X)->lpVtbl->Release(X)) : 0
#define OLE_FREE(x) {\

View File

@ -85,6 +85,7 @@ Init_win32ole_error(void)
eWIN32OLERuntimeError = rb_define_class_under(cWIN32OLE, "RuntimeError", rb_eRuntimeError);
/* Alias of WIN32OLE::RuntimeError, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "RuntimeError", eWIN32OLERuntimeError);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "RuntimeError");
/*
* Document-class: WIN32OLE::QueryInterfaceError
*
@ -93,4 +94,5 @@ Init_win32ole_error(void)
eWIN32OLEQueryInterfaceError = rb_define_class_under(cWIN32OLE, "QueryInterfaceError", eWIN32OLERuntimeError);
/* Alias of WIN32OLE::QueryInterfaceError, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "QueryInterfaceError", eWIN32OLEQueryInterfaceError);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "QueryInterfaceError");
}

View File

@ -1267,6 +1267,7 @@ Init_win32ole_event(void)
cWIN32OLE_EVENT = rb_define_class_under(cWIN32OLE, "Event", rb_cObject);
/* Alias of WIN32OLE::Event, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_EVENT", cWIN32OLE_EVENT);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_EVENT");
rb_define_singleton_method(cWIN32OLE_EVENT, "message_loop", fev_s_msg_loop, 0);
rb_define_alloc_func(cWIN32OLE_EVENT, fev_s_allocate);
rb_define_method(cWIN32OLE_EVENT, "initialize", fev_initialize, -1);

View File

@ -930,6 +930,7 @@ void Init_win32ole_method(void)
cWIN32OLE_METHOD = rb_define_class_under(cWIN32OLE, "Method", rb_cObject);
/* Alias of WIN32OLE::Method, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_METHOD", cWIN32OLE_METHOD);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_METHOD");
rb_define_alloc_func(cWIN32OLE_METHOD, folemethod_s_allocate);
rb_define_method(cWIN32OLE_METHOD, "initialize", folemethod_initialize, 2);
rb_define_method(cWIN32OLE_METHOD, "name", folemethod_name, 0);

View File

@ -425,6 +425,7 @@ Init_win32ole_param(void)
cWIN32OLE_PARAM = rb_define_class_under(cWIN32OLE, "Param", rb_cObject);
/* Alias of WIN32OLE::Param, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_PARAM", cWIN32OLE_PARAM);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_PARAM");
rb_define_alloc_func(cWIN32OLE_PARAM, foleparam_s_allocate);
rb_define_method(cWIN32OLE_PARAM, "initialize", foleparam_initialize, 2);
rb_define_method(cWIN32OLE_PARAM, "name", foleparam_name, 0);

View File

@ -597,6 +597,7 @@ Init_win32ole_record(void)
cWIN32OLE_RECORD = rb_define_class_under(cWIN32OLE, "Record", rb_cObject);
/* Alias of WIN32OLE::Record, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_RECORD", cWIN32OLE_RECORD);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_RECORD");
rb_define_alloc_func(cWIN32OLE_RECORD, folerecord_s_allocate);
rb_define_method(cWIN32OLE_RECORD, "initialize", folerecord_initialize, 2);
rb_define_method(cWIN32OLE_RECORD, "to_h", folerecord_to_h, 0);

View File

@ -893,6 +893,7 @@ void Init_win32ole_type(void)
cWIN32OLE_TYPE = rb_define_class_under(cWIN32OLE, "Type", rb_cObject);
/* Alias of WIN32OLE::Type, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_TYPE", cWIN32OLE_TYPE);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_TYPE");
rb_define_singleton_method(cWIN32OLE_TYPE, "ole_classes", foletype_s_ole_classes, 1);
rb_define_singleton_method(cWIN32OLE_TYPE, "typelibs", foletype_s_typelibs, 0);
rb_define_singleton_method(cWIN32OLE_TYPE, "progids", foletype_s_progids, 0);

View File

@ -830,6 +830,7 @@ Init_win32ole_typelib(void)
cWIN32OLE_TYPELIB = rb_define_class_under(cWIN32OLE, "TypeLib", rb_cObject);
/* Alias of WIN32OLE::TypeLib, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_TYPELIB", cWIN32OLE_TYPELIB);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_TYPELIB");
rb_define_singleton_method(cWIN32OLE_TYPELIB, "typelibs", foletypelib_s_typelibs, 0);
rb_define_alloc_func(cWIN32OLE_TYPELIB, foletypelib_s_allocate);
rb_define_method(cWIN32OLE_TYPELIB, "initialize", foletypelib_initialize, -2);

View File

@ -372,6 +372,7 @@ void Init_win32ole_variable(void)
cWIN32OLE_VARIABLE = rb_define_class_under(cWIN32OLE, "Variable", rb_cObject);
/* Alias of WIN32OLE::Variable, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_VARIABLE", cWIN32OLE_VARIABLE);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_VARIABLE");
rb_undef_alloc_func(cWIN32OLE_VARIABLE);
rb_define_method(cWIN32OLE_VARIABLE, "name", folevariable_name, 0);
rb_define_method(cWIN32OLE_VARIABLE, "ole_type", folevariable_ole_type, 0);

View File

@ -698,6 +698,7 @@ Init_win32ole_variant(void)
cWIN32OLE_VARIANT = rb_define_class_under(cWIN32OLE, "Variant", rb_cObject);
/* Alias of WIN32OLE::Variant, for the backward compatibility */
rb_define_const(rb_cObject, "WIN32OLE" "_VARIANT", cWIN32OLE_VARIANT);
rb_deprecate_constant(rb_cObject, "WIN32OLE" "_VARIANT");
rb_define_alloc_func(cWIN32OLE_VARIANT, folevariant_s_allocate);
rb_define_singleton_method(cWIN32OLE_VARIANT, "array", folevariant_s_array, 2);
rb_define_method(cWIN32OLE_VARIANT, "initialize", folevariant_initialize, -2);

View File

@ -167,11 +167,6 @@ if defined?(WIN32OLE)
assert_instance_of(WIN32OLE, @dict2)
end
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::RuntimeError, ::WIN32OLERuntimeError)
assert_equal(WIN32OLE::QueryInterfaceError, ::WIN32OLEQueryInterfaceError)
end
def test_s_new_exc
assert_raise(TypeError) {
WIN32OLE.new(1)

View File

@ -30,10 +30,6 @@ swbemsink_available =
if defined?(WIN32OLE::Event)
class TestWIN32OLE_EVENT < Test::Unit::TestCase
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Event, ::WIN32OLE_EVENT)
end
def test_s_new_exception
assert_raise(TypeError) {
WIN32OLE::Event.new("A")

View File

@ -20,10 +20,6 @@ if defined?(WIN32OLE::Method)
@m_file_name = WIN32OLE::Method.new(ole_type, "name")
end
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Method, ::WIN32OLE_METHOD)
end
def test_initialize
ole_type = WIN32OLE::Type.new("Microsoft Shell Controls And Automation", "Shell")
assert_raise(TypeError) {

View File

@ -27,10 +27,6 @@ if defined?(WIN32OLE::Param)
@param_key = m_add.params[0]
end
def test_constants_backward_compatibility
assert_equal(WIN32OLE::Param, ::WIN32OLE_PARAM)
end
def test_s_new
assert_raise(ArgumentError) {
WIN32OLE::Param.new("hoge")

View File

@ -67,9 +67,6 @@ End Class
if defined?(WIN32OLE::Record)
class TestWIN32OLE_RECORD < Test::Unit::TestCase
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Record, ::WIN32OLE_RECORD)
end
end
def rbcomtest_exist?

View File

@ -7,10 +7,6 @@ require "test/unit"
if defined?(WIN32OLE::Type)
class TestWIN32OLE_TYPE < Test::Unit::TestCase
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Type, ::WIN32OLE_TYPE)
end
def test_s_progids
progids = WIN32OLE::Type.progids
assert_instance_of(Array, progids)

View File

@ -7,10 +7,6 @@ require "test/unit"
if defined?(WIN32OLE::TypeLib)
class TestWIN32OLE_TYPELIB < Test::Unit::TestCase
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::TypeLib, ::WIN32OLE_TYPELIB)
end
def test_s_typelibs
tlibs = WIN32OLE::TypeLib.typelibs
assert_instance_of(Array, tlibs)

View File

@ -16,10 +16,6 @@ if defined?(WIN32OLE::Variable)
@var2 = variables.find {|v| v.name == 'UILevel'}
end
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Variable, ::WIN32OLE_VARIABLE)
end
def test_initialize
assert_raise(TypeError) {WIN32OLE::Variable.new}
end

View File

@ -17,10 +17,6 @@ if defined?(WIN32OLE::Variant)
WIN32OLE.locale = @orglocale
end
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::Variant, ::WIN32OLE_VARIANT)
end
def test_s_new
obj = WIN32OLE::Variant.new('foo')
assert_instance_of(WIN32OLE::Variant, obj)

View File

@ -9,10 +9,6 @@ if defined?(WIN32OLE::VARIANT)
class TestWin32OLE_VARIANT_MODULE < Test::Unit::TestCase
include WIN32OLE::VARIANT
def test_toplevel_constants_backward_compatibility
assert_equal(WIN32OLE::VariantType, WIN32OLE::VARIANT)
end
def test_variant
assert_equal(0, VT_EMPTY)
assert_equal(1, VT_NULL)