• Welcome to Theos PowerBasic Museum 2017.

The compiler advantage

Started by John Spikowski, August 11, 2013, 07:20:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

John Spikowski

#30
Welcome to Open Source!

O2 is only as good as the sum of it's parts. Charles is the brain, I'm the heart and we need you as a powerful set of lungs to absorb O2 and turn it into life.

Edwin Knoppert

>My ultimate dream IDE is Opengl-driven with its own windows-independent controls

And i by using html5/canvas!
Doable... very!
A combination angular and canvas may do it all..
Just extensive drawing to prepare the controls.

Charles Pegge

#32
There are quite a few experimental constructs in OxygenBasic, which make documentation rather problematic while the rules are continually changing. So examples are the best way to express these constructs in the first instance.

Occasionally some ideas turn out to be unsound and are revoked, along with their examples. But most have survived. The trend has been to eliminate unnecessary syntax and to remove some of the single line restrictions imposed by classical Basic. Anyway, I think the core language is stable enough to do some more detailed documentation now.


To answer the specifics:

This is a simple way to make a union:

type pixel
byte red,green,blue, alpha
=
dword rgba
end type


This is a class header, normally produced automatically from an all-in-one class block The upper part is the static component, including the function address table. The lower part following /\ is the object body. The methods themselves would be contained in a separate methods..end methods block.

class stat
    method sum() as double
    method average() as double
    /\
    da(100) as double
    dn as long
  end class


Oxygen's objects may use 'new' and 'del' to specify that they use heap memory, but objects may also be local, static or global, in which case 'new' and 'del' are not used, and constructor/ destructor methods are not specifically required. These objects work much like a UDT, with all members initially set to null.

A particle class might look like this:

class particle
single posx,posy,posz
single velx,vely,velz
byte red,green,blue,alpha
single duration

method initial
'random ise attributes
...
end method

method update()
'update position etc
end method

method render()
...
end method

end class

particle p[1000]
...



'that' is an override for accessing variables of same name that exist outside the object.





José Roca

Understood. Thanks very much. Now, we have a dichotomy: O2 classes are more suitable for OOP, which is good for Linux users, that don't use COM, and PB is more suitable for COM programming, which is more prevalent in Windows. The ideal, of course, would be to have both in the same compiler.

John Spikowski

#34
I notice very few questions on the PB forum or here about COM usage in PB. What percent of applications built with PB are COM centric? I know you have been able to make PB do everything but make your coffee in the morning but how many others use COM in this way? The other question I have is what percent of your include files are COM related?

I'm truly curious!


Theo Gottwald

#35
Quote from: Zlatko Vid on August 17, 2013, 01:42:46 PM
Hello Power Rangers.. :)
There are already editor for Oxygen Basic called OxyEdit written by me and there is also editor
written in Oxygen called ASciEdit( still in development)...so IDE is not a problem from my point of view.
However i like your SED editor ..especially older version :)

And to not forget thanks again Jose for this great site which is full of programming resourses!

Charles, why don't you include something like this in the package - especially IF it has a SS-Debugger?
This could make things more easy for beginners.

Take the best 3rd Party IDE and put it into the package.

@Jose, the Source code for O2 is available. If you would start at this place you could avoid long discussions and it could start an interesting project here. Drop the Linux part and take it as a Start for something new.

José Roca

> [...] but how many others use COM in this way?

Few, but I no longer care much about what others do. I have other interests now.

> The other question I have is what percent of your include files are COM related?

At least two thirds.

John Spikowski

#37
Thanks for your upfront and honest response!

I still would like to find a way to take advantage of all the hard work you invested in your include files with O2. (which by default would spill over into SB, TB, ...)

José Roca

Quote
@Jose, the Source code for O2 is available. If you would start at this place you could avoid long discussions and it could start an interesting project here. Drop the Linux part and take it as a Start for something new.

What for? Charles is doing an excellent job. Much better than I could do.

John Spikowski

If you could spell out the rules for a conversion from PB to O2, I would write the script in SB. Charles could fill in any holes that might show up in the process.


José Roca

Quote from: John Spikowski on August 18, 2013, 07:38:26 AM
Thanks for your upfront and honest response!

I still would like to find a way to take advantage of all the hard work you invested in your include files with O2. (which by default would spill over into SB, TB, ...)

If I did so much work was because I thought that if PBers weren't using COM was because PB had not a good implementation (just support for Automation and using a syntax that I disliked), and low-level COM needs headers. But I was wrong.

The bad thing is that, since several years ago, almost all of the new Windows technologies are only available as low-level COM servers, and PBers are ignoring them.

José Roca

Quote from: John Spikowski on August 18, 2013, 07:50:56 AM
If you could spell out the rules for a conversion from PB to O2, I would write the script in SB. Charles could fill in any holes that might show up in the process.

It must be easier for Charles to do it directly from the C++ headers. I use a lot of IAutomation interfaces that aren't supported by O2.

John Spikowski

QuoteIt must be easier for Charles to do it directly from the C++ headers.

Charles has already made excellent progress using C headers directly. You're right and an easier way to go.

Charles Pegge

#43
Using and creating COM objects is quite easy. though the sheer scale of the COM system in MS is intimidating enough to put most basic programmers off from tapping into these resources.

Yes, OxygenBasic can use the C++ headers, with very little editing, but all the work that José put into translating those headers and examples, is an awesomely valuable cross-reference.

The essentials for COM programming are built-in to OxygenBasic, namely: guidval and guidtext functions, single-line inheritance, and virtual objects (object pointers). It is also easy to make class factories.

In o2 terms: COM objects are c;ient-side declared extern virtual and server-side implemented as extern.

The word from is used to indicate inheritance from a single class.

Here is is snippet from the voice header: (This would look so much cleaner translated into proper basic :) )


  extern virtual

  '-------------
  class IUnknown
  '=============

    HRESULT QueryInterface(refiid id, pvObject* ppv)
    ULONG   AddRef()
    ULONG   Release()

  end class


  'from sapi.h


  'MIDL_INTERFACE("5EFF4AEF-8487-11D2-961C-00C04F8EE628")
  'ISpNotifySource : public IUnknown
  '
  '--------------------
  class ISpNotifySource
  '====================

    public

    from IUnknown

        HRESULT SetNotifySink(
            /* [in] */ __RPC__in_opt ISpNotifySink *pNotifySink)
       
        HRESULT SetNotifyWindowMessage(
            /* [in] */ HWND hWnd,
            /* [in] */ UINT Msg,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyCallbackFunction(
            /* [in] */ SPNOTIFYCALLBACK *pfnCallback,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyCallbackInterface(
            /* [in] */ ISpNotifyCallback *pSpCallback,
            /* [in] */ WPARAM wParam,
            /* [in] */ LPARAM lParam)
       
        HRESULT SetNotifyWin32Event( void)
       
        HRESULT WaitForNotifyEvent(
            /* [in] */ DWORD dwMilliseconds)
       
        HANDLE GetNotifyEventHandle( void)

  end class



José Roca

#44
Charles, can O2 methods return an structure as the result value of a method, not by passing it by reference? I ask it because then classes could be written to add support to VARIANTs and PROPVARIANTs. My headers contain CVariant.inc, that extends PB's VARIANT support with some 180 methods, and CPropVariant.inc. VARIANTs are used extensively in COM programming and PROPVARIANTs are being used extensively in the latest M$ COM servers.