Author Topic: What translate c++ code to oxygen?  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Alex_Longard

  • Guest
What translate c++ code to oxygen?
« on: January 15, 2015, 07:49:28 AM »
This code from "reaper_plugin.h"
I don't know how to write entrypoint from calling dlls.
Code: [Select]
#define REAPER_PLUGIN_DLL_EXPORT __declspec(dllexport)
#define REAPER_PLUGIN_HINSTANCE HINSTANCE

#define REAPER_PLUGIN_DLL_EXPORT __attribute__((visibility("default")))
#define REAPER_PLUGIN_HINSTANCE void *

#define REAPER_PLUGIN_ENTRYPOINT ReaperPluginEntry
#define REAPER_PLUGIN_ENTRYPOINT_NAME "ReaperPluginEntry"

Help please!!!

Charles Pegge

  • Guest
Re: What translate c++ code to oxygen?
« Reply #1 on: January 15, 2015, 11:11:42 AM »
Hi Alex,

Oxygen can read that part of the header.

What does the rest look like?

Alex_Longard

  • Guest
Re: What translate c++ code to oxygen?
« Reply #2 on: January 15, 2015, 11:32:12 AM »
Hi Charles!
This code have oop-classes
Headers and simple source in attached archive.

.

Charles Pegge

  • Guest
Re: What translate c++ code to oxygen?
« Reply #3 on: January 16, 2015, 11:16:03 PM »
Hi Alex, I am extending Oxygen to understand 'virtual' methods, as presented in the Reaper headers.

This appears to be the only safe class interfacing technique that is inter-operable between different C++ compilers.

Helpful reference:

HowTo: Export C++ classes from a DLL

http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL

Alex_Longard

  • Guest
Re: What translate c++ code to oxygen?
« Reply #4 on: January 17, 2015, 01:13:54 AM »
Hi Charles!
Thanks from article.
My problem is in terms of oxygen that he wrote in the first message.

Charles Pegge

  • Guest
Re: What translate c++ code to oxygen?
« Reply #5 on: January 18, 2015, 12:06:20 AM »
Oxygen Update supporting c++ 'virtual' syntax
http://www.oxygenbasic.org/o2zips/Oxygen.zip

Class Library with virtual interface (and gratuitous curly braces :) )

Foo Example

Class Library Side: (DLL)
Code: OxygenBasic
  1. % filename "foo.dll"
  2. % dll
  3. includepath "$inc/"
  4. include     "RTL32.inc"
  5.  
  6. extern export
  7.  
  8. class FooClass
  9. {
  10.   int GetValue()
  11.   {
  12.    return 42
  13.   }
  14.   void Release()
  15.   {
  16.     if @this then freememory @this
  17.   }
  18. }
  19.  
  20. FooClass* FooObject() 'CLASS FACTORY FUNCTION
  21. {
  22.  FooClass foo at getmemory sizeof FooClass
  23.  ? foo = @FooClass_Table 'ASSIGN METHODS TABLE POINTER
  24. return @foo
  25. }
  26.  
  27. end extern
  28.  


Client Side
Code: OxygenBasic
  1. extern pure virtual lib "foo.dll"
  2. class FooClass
  3. {
  4.   virtual int  GetValue()=0
  5.   virtual void Release()=0
  6. }
  7.  
  8. FooClass* FooObject() 'CLASS FACTORY
  9.  
  10. end extern
  11.  
  12. void main()
  13. {
  14.   FooClass *foo = FooObject
  15.   print foo.GetValue
  16.   foo.Release
  17. }
  18. main
  19.  

A more Basic style:
Code: OxygenBasic
  1. 'CLIENT SIDE, BASIC STYLE
  2. '========================
  3.  
  4. extern pure virtual lib "foo.dll"
  5. class FooClass
  6.   method  GetValue() as int
  7.   method Release()
  8. end class
  9.  
  10. declare FooObject() as FooClass*
  11.  
  12. end extern
  13.  
  14. FooClass *foo = FooObject
  15. print foo.GetValue
  16. foo.Release
  17.  
« Last Edit: January 18, 2015, 01:12:19 AM by Charles Pegge »

Alex_Longard

  • Guest
Re: What translate c++ code to oxygen?
« Reply #6 on: January 18, 2015, 03:28:55 AM »
Hi Charles,
very thanks!!!
I don't quite understand OOP, when he taught C++ does not think that will be useful in the future.

You will be adding new features in the help file?