bugGNU Octave - Bugs: bug #51470, OF-windows: COM objects do not...

 
 

bug #51470: OF-windows: COM objects do not accept method arguments

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Sat 15 Jul 2017 10:09:25 AM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 18 Jul 2017 11:06:16 AM UTC, comment #15: 

Right.
Anyway since this is relevant mostly for developers, and not so much for application in user .m file scripts, I think we can do with just com_invoke.

Philip Nienhuis <philipnienhuis>
Group Member
Tue 18 Jul 2017 12:42:25 AM UTC, comment #14: 

general the should still work, the only functions that will get overloaded will be ones that have the com object as the first praramter.

John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 09:20:37 PM UTC, comment #13: 

Sure, but does the builtin methods.m (in scripts/general/) still work for for classdef & Java objects then? I suppose it'll get shadowed.

Since your fix in comment #4, methods.m in core now does at least something for COM objects.
Looking in scripts/general/methods.m, for "general" objects _methods_ is called (in ov-class.cc) that doesn't know about COM objects:

>> methods (app)
Methods for class octave_com_object:
delete   get      invoke   release  set


which are general COM methods (optionally with "com_" prefixed) while the real list is shown (partly) in comment #9.

So I think when the windows package gets loaded it is _methods_() that needs to be overloaded (as we can't add COM-specific stuff to core Octave).

That's as far as my probably oversimplified OOP reasoning goes :-)

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 08:55:01 PM UTC, comment #12: 

Yes does work - I just created a methods.m file


function output = methods (varargin)

  output = com_invoke (varargin{:});

endfunction


John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 08:48:48 PM UTC, comment #11: 

Yep - close it. I'll take a look and see if methods override is possible.

John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 08:30:28 PM UTC, comment #10: 

BTW shall I set status to "fixed" and close the report?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 08:29:41 PM UTC, comment #9: 

something like:

>> app = actxserver ("Excel.Application")
app =
<COM object _Application (0x0x2a6aee28)>

>> methods (app)
error: methods: Invalid input argument
error: called from
    methods at line 63 column 5

>> com_invoke (app)
ans =
{
  [1,1] = ActivateMicrosoftApp
  [2,1] = AddChartAutoFormat
  [3,1] = AddCustomList
  [4,1] = AddRef
  [5,1] = Calculate
  [6,1] = CalculateFull
  [7,1] = CalculateFullRebuild
  [8,1] = CalculateUntilAsyncQueriesDone
  [9,1] = CentimetersToPoints
  [10,1] = CheckAbort
  [11,1] = CheckSpelling
  [12,1] = ConvertFormula
  [13,1] = DDEExecute
  [14,1] = DDEInitiate
:
  [70,1] = Save
  [71,1] = SaveWorkspace
  [72,1] = SendKeys
  [73,1] = SetDefaultChart
  [74,1] = SharePointVersion
  [75,1] = Support
  [76,1] = Undo
  [77,1] = Union
  [78,1] = Volatile
  [79,1] = Wait
  [80,1] = _Evaluate
  [81,1] = _FindFile
  [82,1] = _MacroOptions
  [83,1] = _Run2
  [84,1] = _WSFunction
  [85,1] = _Wait
}


I'm not so familiar with OOP; but anyway, what I think is that as methods(app) doesn't work, maybe _COM_.cc can contain a function that overloads or supplements the core Octave methods() function to also work on COM objects?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 06:52:29 PM UTC, comment #8: 

Can you give an example of what you mean for the overloading?

John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 06:48:55 PM UTC, comment #7: 

already pushed to of-windows



John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 06:37:31 PM UTC, comment #6: 

Thanks, works fine here.
Will you push the fix to the of-windows repo?


BTW I saw that there's no "methods" call for COM objects, yet

com_invoke (<COM-object>)

w/o specifying a method will return a list of methods for that object. Would it be difficult to use this info for making an overloading "methods" function for COM objects?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 05:06:31 PM UTC, comment #5: 

Wow, that it is so easy.
Thanks, I'll give it a try.
So that'll be windows-1.2.5.soon I guess.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 04:52:27 PM UTC, comment #4: 
John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 03:30:34 PM UTC, comment #3: 

Yeah looks like it works if I add to the com object:


bool isobject (void) const { return true; }

John Donoghue <lostbard>
Group Member
Mon 17 Jul 2017 03:09:35 PM UTC, comment #2: 

It is possible to work around it using the com_invoke, com_get and com_set functions (much like bug #511532 could be worked around using javaMethod), but that's quite clumsy and does not make for easy to maintain code.

Mike's fix for bug #51152 merely comprised addition of a "isjava(<obj>)" call to an if clause in pt-eval.cc. However that is relatively easy as isjava() is built into core Octave, while an "iscom()" call would have to come from an add-on package.
Maybe COM objects can be masqueraded as general objects?

Philip Nienhuis <philipnienhuis>
Group Member
Mon 17 Jul 2017 01:09:08 PM UTC, comment #1: 

subref function in windows _COM_.cc is giving just a "." as the type - in octave 4.2.1 gives ".("

John Donoghue <lostbard>
Group Member
Sat 15 Jul 2017 10:09:25 AM UTC, original submission:  

I'm a little afraid this is another manifestation of bug #51152

COM objects (ActiveX objects) do not accept arguments, sometimes not even parentheses enclosing the argument(s).
I hit this when investigating io package problems while invoking Excel through ActiveX.  If needed I can show how to reproduce the bug with LibreOffice, but then I'd need to search & undig some old scripts.  But the bug can simply be demonstrated with Notepad.exe as well.

Steps to reproduce:

  • install and load windows package
  • then:


>> app = actxserver ("WScript.Shell")
app =

<COM object IWshShell3 (0x0x11def570)>

>> app.run ("NOTEPAD.EXE", 3)
error: com_get: property/method invocation on the COM object failed with error `0x80020003'


Expected result (here with Octave-3.9.0+ I still had installed):

>> app = actxserver ("WScript.Shell")
app =

<COM object IWshShell3 (0x0x8861768)>

>> app.run ("NOTEPAD.EXE", 3)
ans = 0


(the latter hidden behind a full-screen Notepad window. Just use Alt-tab to get to the Octave terminal)
To close the app object, do File | Exit in Notepad and in Octave just:
delete (app);


Philip Nienhuis <philipnienhuis>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-17 philipnienhuis StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2017-07-17 philipnienhuis StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code