Oxygen Basic

Programming => Problems & Solutions => Topic started by: JRS on November 11, 2016, 02:44:05 PM

Title: DLLC
Post by: JRS on November 11, 2016, 02:44:05 PM
Charles,

I tried to compile the DllcBuild.o2bas file but it doesn't create the DLLC.dll in modules and just flashes this dialog which looks like a hard coded path coming from somewhere.

John


.
Title: Re: DLLC
Post by: Arnold on November 12, 2016, 03:25:52 AM
Hi John,

it seems that the path is coded into the new co2.exe. If I create the directory c:\cevp\code\oxygenbasic and copy oxygen.dll into this folder then compiling will work. Another way would be to compile with gxo2.exe, but:

@Charles - will gxo2.exe work the same way as co2.exe? Gxo2.exe has a date of 12/06/15 whereas co2.exe shows a date of 28/10/16.

Roland
Title: Re: DLLC
Post by: JRS on November 12, 2016, 10:20:35 AM
Thanks Roland for the info.

I'll wait until Charles has something stable for me to work with.

Title: Re: DLLC
Post by: Charles Pegge on November 13, 2016, 01:53:46 AM

Hi John,

My directectory mappings differ from yours, so I have made DLLC building more generic. Put the contents of this zip into projectsC\ScriptBasic\.

You can adapt this batch file to you own system:
Code: [Select]
..\..\gxo2 DLLCbuild.o2bas
..\..\gxo2 DLLCtestDLL.o2bas
copy ..\..\Oxygen.dll  \ScriptBasic\modules
copy DLLC*.dll          \ScriptBasic\modules
pause
[/code]


.
Title: Re: DLLC
Post by: Charles Pegge on November 13, 2016, 02:01:02 AM

Hi Roland,

co2.exe and gxo2.exe can be used the same way. co2 is more prone to unprovoked attacks from anti-virus software, otherwise it is my preferred compiler.
Title: Re: DLLC
Post by: Arnold on November 13, 2016, 04:23:32 AM
Hi Charles,

I used BuildCo2.bat in folder tools to build co2 again, copied co2.exe to \OxygenBasic folder,  and now compiling will work with my system. But checking with a hex editor I see that there is still a difference between co2.exe and gxo2.exe:
co2.exe now points to c:\oxygenbasic\oxygen.dll, gxo2.exe points only to oxygen.dll. Co2.exe of the distribution before also points to oxygen.dll without path. How did you manage this?

Most probably I still have not understood the complete systematic of OxygenBasic. I read through -> Introducing Oxygen/Architecture and I am not sure if all of this is still valid. But I think the real strength lies in oxygen.dll, co2.exe and gxo2.exe are helper programs. So I could use e.g. an older co2.exe and will get the same results with oxygen.dll in the latest distribution?

BTW according to Applog.txt, Oxylog.txt you added a lot of new features to Oxygen. It will take some time to explore all the possible application spectrum. Is OxygenBasic still in Alpha stage? 

Roland
Title: Re: DLLC
Post by: JRS on November 13, 2016, 09:26:25 AM
Quote
You can adapt this batch file to you own system:

Thanks Charles!

I tend to put all non-SB ext. mod DLL's in my Script BASIC bin directory as it''s in the Windows path and it keeps all my dependencies together in one place.

Can I now use DLLC quads for v7_val_t?

Update:

I gave your pre-compiled DLLC a try with my JS generic DLL and it exception errored trying to run a test of the O2 style FFI defines. (using q for the v7_val_t variable)
Title: Re: DLLC
Post by: JRS on November 13, 2016, 08:59:39 PM
I'm getting close to wrapping up the first phase of the JS (JavaScript Engine) extension module for Script BASIC using C BASIC. I think I'm going to like Stringify.

Code: Script BASIC
  1. IMPORT js.inc
  2.  
  3. JS::CREATE
  4. myobj = JS::MK_OBJECT()
  5. JS::DEF(myobj, "myprop_1", 0, JS::MK_NUMBER(64))
  6. JS::DEF(myobj, "myprop_2", 0, JS::MK_NUMBER(1.23))
  7. JS::DEF(myobj, "myprop_3", 0, JS::MK_STRING("JavaScript"))
  8. PRINT JS::STRINGIFY(myobj, JS::JSON),"\n"
  9. JS::DESTROY
  10.  


jrs@jrs-laptop:~/sb/examples/js$ scriba js_stringify.sb
{"myprop_3":"JavaScript","myprop_2":1.23,"myprop_1":64}
jrs@jrs-laptop:~/sb/examples/js$

Title: Re: DLLC
Post by: Charles Pegge on November 14, 2016, 02:36:19 AM
Hi Roland,

Gxo2 is compiled with Freebasic, whereas co2 is compiled with Oxygen and also uses a few o2 inc files, including sysutil, and parseutil so their internals will diverge. The compiler could be written in any language, and include customised preprocessing and postprocessing.

I think the full pathname that you see for oxygen.dll comes from librarypath "$\"

There is lots of new material in this release of o2, and I don't anticipate further major changes to the o2 core, but I see graphics, GUI and audio as major areas of interest for developing an outer shell.
Title: Re: DLLC
Post by: Charles Pegge on November 14, 2016, 03:25:41 AM
Hi John,

Are you passing the quad value directly?
quads passed by reference are still interpreted as double. I have not followed thru yet

returned arrays should also be undefed before reuse. undef is a good precaution anyway.

Code: [Select]
ReturnQuadQ       = dllproc(mylib,"returnquadq q=(q value)" )
...
undef aq
aq[0]=7
aq[1]=9
ap=dllCall(returnquadQ,aq)
print "Return QuadQ: "  & ap[0] & "," & ap[1] &  "\n"

undef ap
ap=dllCall(returnquadQ,aq)
print "Return QuadQ: "  & ap[0] & "," & ap[1] &  "\n"

undef ar
ar=dllCall(returnquadQ,ap)
print "Return QuadQ: "  & ar[0] & "," & ar[1] &  "\n"
Title: Re: DLLC
Post by: Arnold on November 14, 2016, 03:40:10 AM
Hi Charles,

thank you for the hint. I found the statement in sysuil.inc and commented it out for this special purpose. After running BuildCos2.bat again everything will run ok now. I think using the full path of oxygen.dll in co2.exe is a bit problematic if I change the folder's name of Oxygenbasic or use e.g. an usb stick. But now I know what I can do in a similar situation.

Roland
Title: Re: DLLC
Post by: Charles Pegge on November 14, 2016, 04:09:53 AM
Yes, I see the problem. The library path to Oxygen gets 'baked' at co2 compile time. This librarypath line should be omitted. Thanks Roland.
Title: Re: DLLC
Post by: JRS on November 14, 2016, 09:25:15 AM
I don't get how to assign a v7_val_t to a O2 quad and call a V7 function. How do I break up an unsigned long long into two 32 bit integer values? I'm confused!
Title: Re: DLLC
Post by: JRS on November 14, 2016, 09:48:20 AM
OT

I stumbled upon a JavaScript interactive interpreter written in JavaScript. For me it's a good resource of advanced JavaScript techniques.

Quote
JS-Interpreter (https://github.com/NeilFraser/JS-Interpreter)

A sandboxed JavaScript interpreter in JavaScript. Execute arbitrary JavaScript code line by line in isolation and safety.

Live demo (https://neil.fraser.name/software/JS-Interpreter/)

Documentation (https://neil.fraser.name/software/JS-Interpreter/docs.html)



Title: Re: DLLC
Post by: Charles Pegge on November 14, 2016, 10:11:25 AM
Hi John,

All we are doing is splitting the 64 bit value into 2 32 bit values and storing them in an  array  of 2 integer elements. ar[0] has the lower 32 bits and ar[1] has the upper bits. This array can be passed around like a simple variable. The signed/unsigned status does not matter when you are only interested in bits.

SB array values are not contiguous internally so DLLC has to line them up before passing them to a DLL function

I have nearly finished Quads passed byref (q*) and Quads in data structures.

Title: Re: DLLC
Post by: JRS on November 14, 2016, 10:35:01 AM
I understand now. I will wait until you have passing quads working before giving it another attempt. In reality all I need for V7 at the moment in DLLC is a way to pass a v7_val_t type to V7 functions. I don't need to mess with them in SB as they are blackbox variables only to be passed and not touched. The union  trick I'm doing in C seems to be working out well,

My plan is to just replace the SB C extension module definitions in js.inc with DLLC FFI calls and use the SB wrapper functions and constants already in place.
Title: Re: DLLC
Post by: JRS on November 14, 2016, 09:34:14 PM
Here is the V7 JavaScript engine extension module functions implemented at this time.  The next round will be JavaScript calling the Script BASIC embedding API to call functions and access variables. I have Windows 32 bit and Ubuntu 16.04 64 bit versions of the the interface built and could use some help beta testing if you know SB and JS. Send me a PM if you're interested.

Code: Script BASIC
  1. ' CORE
  2. DECLARE SUB      js_create                  ALIAS "js_create"                 LIB "js"
  3. DECLARE SUB      js_destroy                 ALIAS "js_destroy"                LIB "js"
  4. DECLARE SUB      js_get_global              ALIAS "js_get_global"             LIB "js"
  5. DECLARE SUB      js_get_this                ALIAS "js_get_this"               LIB "js"
  6. DECLARE SUB      js_get_arguments           ALIAS "js_get_arguments"          LIB "js"
  7. DECLARE SUB      js_get_arg                 ALIAS "js_get_arg"                LIB "js"
  8. DECLARE SUB      js_get_argc                ALIAS "js_get_argc"               LIB "js"
  9. DECLARE SUB      js_own                     ALIAS "js_own"                    LIB "js"
  10. DECLARE SUB      js_disown                  ALIAS "js_disown"                 LIB "js"
  11. DECLARE SUB      js_set_gc_enabled          ALIAS "js_set_gc_enabled"         LIB "js"
  12. DECLARE SUB      js_interrupt               ALIAS "js_interrupt"              LIB "js"
  13. DECLARE SUB      js_get_parser_error        ALIAS "js_get_parser_error"       LIB "js"
  14.  
  15. ' PRIMITIVES
  16. DECLARE SUB      js_mk_number               ALIAS "js_mk_number"              LIB "js"
  17. DECLARE SUB      js_get_double              ALIAS "js_get_double"             LIB "js"
  18. DECLARE SUB      js_get_int                 ALIAS "js_get_int"                LIB "js"
  19. DECLARE SUB      js_is_number               ALIAS "js_is_number"              LIB "js"
  20. DECLARE SUB      js_mk_boolean              ALIAS "js_mk_boolean"             LIB "js"
  21. DECLARE SUB      js_get_bool                ALIAS "js_get_bool"               LIB "js"
  22. DECLARE SUB      js_is_boolean              ALIAS "js_is_boolean"             LIB "js"
  23. DECLARE SUB      js_mk_null                 ALIAS "js_mk_null"                LIB "js"
  24. DECLARE SUB      js_is_null                 ALIAS "js_is_null"                LIB "js"
  25. DECLARE SUB      js_mk_undefined            ALIAS "js_mk_undefined"           LIB "js"
  26. DECLARE SUB      js_is_undefined            ALIAS "js_is_undefined"           LIB "js"
  27. DECLARE SUB      js_mk_foreign              ALIAS "js_mk_foreign"             LIB "js"
  28. DECLARE SUB      js_get_ptr                 ALIAS "js_get_ptr"                LIB "js"
  29. DECLARE SUB      js_is_foreign              ALIAS "js_is_foreign"             LIB "js"
  30.  
  31. ' STRINGS
  32. DECLARE SUB      js_mk_string               ALIAS "js_mk_string"              LIB "js"
  33. DECLARE SUB      js_is_string               ALIAS "js_is_string"              LIB "js"
  34. DECLARE SUB      js_get_string              ALIAS "js_get_string"             LIB "js"
  35. DECLARE SUB      js_get_cstring             ALIAS "js_get_cstring"            LIB "js"
  36.  
  37. ' OBJECTS
  38. DECLARE SUB      js_mk_object               ALIAS "js_mk_object"              LIB "js"
  39. DECLARE SUB      js_is_object               ALIAS "js_is_object"              LIB "js"
  40. DECLARE SUB      js_get_proto               ALIAS "js_get_proto"              LIB "js"
  41. DECLARE SUB      js_set_proto               ALIAS "js_set_proto"              LIB "js"
  42. DECLARE SUB      js_get                     ALIAS "js_get"                    LIB "js"
  43. DECLARE SUB      js_def                     ALIAS "js_def"                    LIB "js"
  44. DECLARE SUB      js_set                     ALIAS "js_set"                    LIB "js"
  45. DECLARE SUB      js_del                     ALIAS "js_del"                    LIB "js"
  46. DECLARE SUB      js_init_prop_iter_ctx      ALIAS "js_init_prop_iter_ctx"     LIB "js"
  47. DECLARE SUB      js_next_prop               ALIAS "js_next_prop"              LIB "js"
  48. DECLARE SUB      js_destruct_prop_iter_ctx  ALIAS "js_destruct_prop_iter_ctx" LIB "js"
  49. DECLARE SUB      js_is_instanceof           ALIAS "js_is_instanceof"          LIB "js"
  50. DECLARE SUB      js_is_instanceof_v         ALIAS "js_is_instanceof_v"        LIB "js"
  51.  
  52. ' ARRAYS
  53. DECLARE SUB      js_mk_array                ALIAS "js_mk_array"               LIB "js"
  54. DECLARE SUB      js_is_array                ALIAS "js_is_array"               LIB "js"
  55. DECLARE SUB      js_array_length            ALIAS "js_array_length"           LIB "js"
  56. DECLARE SUB      js_array_push              ALIAS "js_array_push"             LIB "js"
  57. DECLARE SUB      js_array_get               ALIAS "js_array_get"              LIB "js"
  58. DECLARE SUB      js_array_set               ALIAS "js_array_set"              LIB "js"
  59. DECLARE SUB      js_array_del               ALIAS "js_array_del"              LIB "js"
  60.  
  61. ' EXECUTION
  62. DECLARE SUB      js_exec                    ALIAS "js_exec"                   LIB "js"
  63. DECLARE SUB      js_exec_file               ALIAS "js_exec_file"              LIB "js"
  64. DECLARE SUB      js_apply                   ALIAS "js_apply"                  LIB "js"
  65. DECLARE SUB      js_parse_json              ALIAS "js_parse_json"             LIB "js"
  66. DECLARE SUB      js_parse_json_file         ALIAS "js_parse_json_file"        LIB "js"
  67.  
  68. 'REGEX
  69. DECLARE SUB      js_mk_regexp               ALIAS "js_mk_regexp"              LIB "js"
  70. DECLARE SUB      js_is_regexp               ALIAS "js_is_regexp"              LIB "js"
  71.  
  72. ' UTILITY
  73. DECLARE SUB      js_stringify               ALIAS "js_stringify"              LIB "js"
  74. DECLARE SUB      js_println                 ALIAS "js_println"                LIB "js"
  75.  
  76. DECLARE SUB      SB_shifts                  ALIAS "SB_shifts"                 LIB "js"
  77. DECLARE COMMAND  js_iif                     ALIAS "js_iif"                    LIB "js"
  78.  
Title: Re: DLLC
Post by: Charles Pegge on November 15, 2016, 09:37:12 AM
When I study this  J7 stuff, I feel quite depleted, so I am not overly keen to pursue the subject, unless there is a very good reason to do so.
Title: Re: DLLC
Post by: JRS on November 15, 2016, 12:14:30 PM
Charles,

If the V7 JavaScript engine has no appeal to you for O2 and is only a DLLC would be nice to have project then I have a C solution for 32 bit Windows that is working.

Please feel free to delete the thread.

Title: Re: DLLC
Post by: Charles Pegge on November 16, 2016, 01:08:59 AM
Well,  o2  needs some more training to cope with these constructs which have embedded enum and struct

Code: [Select]
int v7_stack_stat(struct v7 *v7, enum v7_stack_stat_what what);

Code: [Select]
typedef enum v7_err(v7_cfunction_t)(struct v7 *v7, v7_val_t *res);
Title: Re: DLLC
Post by: JRS on November 16, 2016, 09:23:02 AM
Seriously, if there isn't an overwhelming desire to have JavaScript as an extension to O2, PLEASE don't feel this has any effect on my efforts with the V7 library. If it wasn't going to be a big thing to get v7_val_t types supported in DLLC, It would have been cool to script an FFI for it.

Thanks for all your efforts to date, You are a good friend and amazing developer.

Title: Re: DLLC
Post by: Charles Pegge on November 18, 2016, 03:27:19 AM

Hi John,

It's worth assimilating some more C in any case.

here is another obscurity:

unsigned init : 1;
Code: [Select]
struct prop_iter_ctx {
#if V7_ENABLE__Proxy
  struct prop_iter_proxy_ctx *proxy_ctx;
#endif
  struct v7_property *cur_prop;

  unsigned init : 1;
};

At least we can get through the v7 header now :)
Title: Re: DLLC
Post by: JRS on November 18, 2016, 08:02:53 AM
Quote
At least we can get through the v7 header now

Outstanding!

Nice job Charles.

I found a TYPE-Oh with the js_mk_array function and had to recompile the DLL.


Title: Re: DLLC
Post by: JRS on November 21, 2016, 10:23:44 AM
The Windows version of the JS extension module is too fragile for me to continue with it at this time. I'm hoping you have better luck with O2 and maybe DLLC if it is doable.
Title: Re: DLLC
Post by: Mike Lobanovsky on November 21, 2016, 06:33:07 PM
here is another obscurity:

unsigned init : 1;

This looks like a 1-bit wide bitfield but the isolated context it is used in is ridiculous. There are certain restrictions in C/C++ as to the alignment of such fields in the common data bit sequence. As a minimum, the remaining bits of the member must be declared explicitly, even if only anonymously, otherwise the compiler is very likely to choke:
Code: C
  1. unsigned init: 1;
  2. unsigned _:    31; // under 32 bits
or
Code: C
  1. unsigned init: 1;
  2. unsigned _:    63; // under 64 bits

If there are more such instances throughout the sources, no wonder this entire V7 thingy is so fragile.
Title: Re: DLLC
Post by: JRS on November 21, 2016, 07:29:02 PM
Thanks Mike for chiming in with your perspective,

Here is what I'm dealing with, The following generic C example of what I'm trying to do with the Script BASIC ext. module works. I have spent a day or more trying to get to the bottom of this, The error V7 returns after the v7_apply() is that the func object value isn't invalid. The same code runs great on Ubuntu 64 bit,.

Code: C
  1. #include <stdio.h>
  2. #include "v7.h"
  3.  
  4. int main(void) {
  5.   struct v7 *v7 = v7_create();
  6.   v7_val_t res, func, args, funcrtn;
  7.   int rcode;
  8.   rcode = v7_exec(v7, "var sum = function(a, b){return a + b;};", &res);
  9.   func = v7_get(v7, v7_get_global(v7), "sum", 3);
  10.   args = v7_mk_array(v7);
  11.   v7_array_push(v7, args, v7_mk_number(v7, 123.0));
  12.   v7_array_push(v7, args, v7_mk_number(v7, 0.456));
  13.   rcode = v7_apply(v7, func, 0, args, &funcrtn);
  14.   printf("%g\n", v7_get_double(v7, funcrtn));
  15.   v7_destroy(v7);
  16.   return 0;
  17. }
  18.  


C:\sbgcc\source\extensions\js>gcc callfunc.c -o callfunc C:\TDM-GCC-32\lib\js_imp.a

C:\sbgcc\source\extensions\js>callfunc
123.456

C:\sbgcc\source\extensions\js>


BTW: - I just realized that I used the js_imp.a for the generic C example and it was generated as part of the Script BASIC extension module. A dual purpose DLL.  8)
Title: Re: DLLC
Post by: Charles Pegge on November 23, 2016, 01:05:21 PM
Hi Mike,

I did not see any further bit fields in the J7 header.

the bit filed specifier might be useful to coders but is not much use for the compiler, and the next o2 will swallow them undigested. The padding is determined by the member type, thus normal padding rules are unaffected.

PS:

Partly as a consequence of the J7 syntax demands, I have made a few minor maintenance alterations to OxyScheme. Do you still have an interest in Lisp/Scheme?
Title: Re: DLLC
Post by: JRS on November 24, 2016, 01:21:50 PM
Quote
Partly as a consequence of the J7 syntax demands,

I'm looking forward to the JIT tricks that can be performed with O2 hosting a JavaScript engine.
Title: Re: DLLC
Post by: JRS on December 02, 2016, 09:13:53 PM
I finally got Windows 10 installed in a VirtualBox and Script BASIC seems to be working fine. The sbiup.exe Windows version with theme support also works on Win10.


.
Title: Re: DLLC
Post by: Mike Lobanovsky on December 03, 2016, 04:29:58 AM
John,

Does VirtualBox offer regular guest additions for Windows 10?

I got native Win 10 Pro Anniversary Edition installed only recently for field testing when Gerome reported that his office Win 10 Defender flags the FBSL v3.5 RC2 DL package as containing a trojan. As it turned out in the end however it wasn't really Defender, but rather the silly heuristics of Avira, that was throwing that false alarm. The DL contains a 2.5KB large Fbsl_Tiny.exe that has an icon and a manifest but omits a version info resource for the sake of smaller size -- somethings that's sufficient to send Avira nuts.

So, Win 10 stays henceforth on one of my PCs for testing. It's been however prettified in a non-intrusive, non-patching fashion to regain its unofficial Aero Glass and Aero Lite (~Basic in former MS Windows) theming functionality. Its poor-man's original system theming was far too much for my intricate artistic self to look at. :)

.
Title: Re: DLLC
Post by: JRS on December 03, 2016, 10:26:44 AM
Quote
Does VirtualBox offer regular guest additions for Windows 10?

Yes and a selection for Windows 10 as an OS.

This time around I'm using my laptop that has 8 cores and better graphics. Im giving the VM a couple cores and a gig and a half of memory which seems to be enough to run respectfully. I'm using the 32 bit version of Windows 10. Doing the same for Windows 7. I have a 64 bit Windows 7 partition if I want to go there for some reason.

I'm not in love with the Windows 10 UI as it's bland with little distinction. I have to support customers that aren't willing or can't change it to look like Windows 7 even though I like your setup.

I was able to disable one drive, defender, auto updates and all the feedback notifications back to Microsoft. It really runs rather well as a VM. It seems to run faster and smoother that my Win7 32 bit VM.

Update - I do have one problem of adding shared drives. (VirtualBox Linux directories) I'm getting by with Drag & Drop.
Title: Re: DLLC
Post by: JRS on December 04, 2016, 06:12:42 PM
Mike,

I've been setting Windows 10 up for development and noticed that libpthread.a is now supported and I don't have to use a 3rd party library.


C:\sbgcc\source>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=C:/TDM-GCC-32/bin/../libexec/gcc/mingw32/5.1.0/lto-wrapper.exe
Target: mingw32
Configured with: ../../../src/gcc-5.1.0/configure --build=mingw32 --enable-languages=ada,c,c++,fortran,lto,objc,obj-c++ --enable-libgomp --enable-lto --enable-graphite --enable-libstdcxx-debug --enable-threads=posix --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libstdcxx-threads --enable-libstdcxx-time --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry --disable-symvers --enable-cxx-flags='-fno-function-sections -fno-data-sections -DWINPTHREAD_STATIC' --prefix=/mingw32tdm --with-local-prefix=/mingw32tdm --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugurl=http://tdm-gcc.tdragon.net/bugs
Thread model: posix
gcc version 5.1.0 (tdm-1)

C:\sbgcc\source>

C:\sbgcc\source\bin\exe>ver

Microsoft Windows [Version 10.0.14393]

C:\sbgcc\source\bin\exe>scriba -v
ScriptBasic v2.2
Variation >>WIN10-32<< build 1
Magic value 859010868
Node size is 16
Extension interface version is 11
Compilation: Dec  4 2016 18:47:54
Executable: C:\sbgcc\source\bin\exe\scriba.exe

C:\sbgcc\source\bin\exe>


While doing a walk-about through the SB source I found this test code that shows how easy it is to work with the embedding API.

Code: C
  1. unsigned long i=0;
  2. unsigned long min,max,act;
  3. pSbData pRetVale;
  4.   while( 1 ){
  5.     i++;
  6.     if( i%10000 == 0 ){
  7.       testa_ReportLeak();
  8. #define PRSEG(X)      alloc_GetStat(X,&min,&max,&act);printf("Segment %s is %d\n",#X,act);
  9.       PRSEG(pProgram->pMEM);
  10.       PRSEG(pProgram->pEXE->pMo);
  11.       PRSEG(pProgram->pEXE->pMemorySegment);
  12.       printf("kukk %d\n",i/10000);
  13.       getchar();
  14.       }
  15.     pRetVale = scriba_NewSbData(pProgram);
  16.     scriba_CallArgEx(pProgram,scriba_LookupFunctionByName(pProgram,"main::pred_1"),pRetVale,0,NULL);
  17.     scriba_DestroySbData(pProgram,pRetVale);
  18.     }
  19. }
  20.  
  21.   printf("testvar type is %d\n",scriba_GetVariableType(pProgram,
  22.   scriba_LookupVariableByName(pProgram,"main::testvar")));
  23.   scriba_GetVariable(pProgram,
  24.                      scriba_LookupVariableByName(pProgram,"main::testvar"),
  25.                      &psb
  26.     );
  27.   printf("testvar from C is %s\n",scriba_GetString(pProgram,*psb));
  28.  
  29.   scriba_SetVariable(pProgram,scriba_LookupVariableByName(pProgram,"main::testvar"),
  30.                      SBT_ZCHAR,1,2.2,"kukac",4);
  31.   scriba_CallArgEx(pProgram,scriba_LookupFunctionByName(pProgram,"main::thatfunc"),&RetVale,4,p);
  32.  


Title: Re: DLLC
Post by: Mike Lobanovsky on December 05, 2016, 01:25:29 AM
John,

Tell you more: if you have Windows 10 Anniversary Edition then you can have full-blown Ubuntu directly in the Windows console (http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/). :D

It's like a mirror reflection of Wine: Windows now has its own Linux subsystem with apt, ssh, rsync, find, grep, awk, sed, sort, xargs, md5sum, gpg, curl, wget, apache, mysql, python, perl, ruby, php, gcc, tar, vim, emacs, diff, patch... And a zillion more directly from the Ubuntu archives!

You don't need no dual bootin' any more, John. If you're under Windows again, you're in a programmer's heaven. :)
Title: Re: DLLC
Post by: JRS on December 05, 2016, 09:43:45 AM
I'm running the most current version of Windows 10 32 bit. I don't think the Ubuntu stuff is offered in the 32 bit version of Windows 10.

I'm happy just the way things are. I have no need for a Linux abortion running in Windows.

The article states this isn't the Linux kernel running with Windows but a busybox like implementation. (Microsoft's Windows Android effort redirected)


Title: Re: DLLC
Post by: Mike Lobanovsky on December 05, 2016, 12:50:23 PM
MS Windows Linux Subsystem was created in close co-operation with Canonical, so it shouldn't be a piece of goofy junk like Wine or ReactOS that will require decades to debug and complete. I think its server functionality will be fully unlocked in Windows Server 2016 any time soon -- that's the only reasonable explanation for the entire effort, the only one ever taken by MS to jump onto the trendy bandwagon in time. :)

And it will only be a matter of months before some inquisitive enthusiasts find ways and means to add Linux GUI functionality to, or unlock it in, the current terminal-only implementation, if only MS doesn't do that itself to do away with Oracle, VMware et al. virtual machine vendors' competition altogether in one swoop.

What made you favor a 32-bit installation over 64 bits?
Title: Re: DLLC
Post by: JRS on December 05, 2016, 03:36:16 PM
Quote
What made you favor a 32-bit installation over 64 bits?

I don't plan to run Office or Photoshop in the VM and only doing 32 bit Windows development. (no SysWoW64 emultation) The 32 bit version runs much faster in a VM than the 64 bit version does in its own partition running native. I also set the preferences for speed over fluff. I see little interest in the average Windows developer to invest in 64 bit.
Title: Re: DLLC
Post by: JRS on December 06, 2016, 03:56:23 PM
If you don't need a Linux sub-system for your Windows 10 install, consider busybox-w32 (https://frippery.org/busybox/).


C:\Users\John>busybox
BusyBox v1.26.0-FRP-811-g71ecc80 (2016-11-29 13:35:05 GMT) multi-call binary.
(mingw32-gcc 6.2.0-1.fc25; mingw32-crt 5.0.0-1.fc25)

BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list
   or: busybox --install [DIR]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  The shell in this build
        is configured to run built-in utilities without $PATH search.
        You don't need to install a link to busybox for each utility.
        To run external program, use full path (/sbin/ip instead of ip).

Currently defined functions:
        [, [[, ar, ash, awk, base64, basename, bash, bunzip2, bzcat, bzip2, cal, cat, catv, chmod, cksum, clear, cmp,
        comm, cp, cpio, cut, date, dc, dd, df, diff, dirname, dos2unix, dpkg-deb, du, echo, ed, egrep, env, expand,
        expr, false, fgrep, find, fold, ftpget, ftpput, getopt, grep, groups, gunzip, gzip, hd, head, hexdump, id,
        ipcalc, kill, killall, less, ln, logname, ls, lzcat, lzma, lzop, lzopcat, man, md5sum, mkdir, mktemp, mv, nc,
        od, patch, pgrep, pidof, printenv, printf, ps, pwd, rev, rm, rmdir, rpm2cpio, sed, seq, sh, sha1sum, sha256sum,
        sha3sum, sha512sum, shuf, sleep, sort, split, stat, strings, sum, tac, tail, tar, tee, test, touch, tr, true,
        truncate, uname, uncompress, unexpand, uniq, unix2dos, unlink, unlzma, unlzop, unxz, unzip, usleep, uudecode,
        uuencode, vi, wc, wget, which, whoami, whois, xargs, xz, xzcat, yes, zcat

C:\sbgcc\modules>busybox date
Tue Dec  6 15:54:31 Pacific Standard Time 2016

C:\sbgcc\modules>busybox sh
C:/sbgcc/modules $ ls -l
total 3864
-rw-rw-r--    1 John     John         45568 Dec 01 22:55 cgi.dll
-rw-rw-r--    1 John     John         12800 Dec 01 22:55 cio.dll
-rw-rw-r--    1 John     John        245760 Dec 05 21:00 curl.dll
-rw-rw-r--    1 John     John         21504 Dec 01 22:55 dbg.dll
-rw-rw-r--    1 John     John         45568 Dec 01 22:55 dllc.dll
-rw-rw-r--    1 John     John         53248 Dec 02 23:58 dyc.dll
-rw-rw-r--    1 John     John        131072 Dec 05 22:42 gfx.dll
-rw-rw-r--    1 John     John         16896 Dec 01 22:55 hash.dll
-rw-rw-r--    1 John     John        321024 Dec 01 22:55 js.dll
-rw-rw-r--    1 John     John         26112 Dec 01 22:55 mt.dll
-rw-rw-r--    1 John     John         56320 Dec 01 22:55 mxml.dll
-rw-rw-r--    1 John     John         24064 Dec 01 22:55 mysql.dll
-rw-rw-r--    1 John     John         20992 Dec 01 22:55 nt.dll
-rw-rw-r--    1 John     John         17920 Dec 01 22:55 odbc.dll
-rw-rw-r--    1 John     John         52224 Dec 02 19:49 pui.dll
-rw-rw-r--    1 John     John         50688 Dec 01 22:55 re.dll
-rw-rw-r--    1 John     John        458752 Dec 01 22:55 sbt.dll
-rw-rw-r--    1 John     John         22016 Dec 01 22:55 sdbg.dll
-rw-rw-r--    1 John     John        660480 Dec 01 22:55 sqlite.dll
-rw-rw-r--    1 John     John         15872 Dec 01 22:55 t.dll
-rw-rw-r--    1 John     John         12288 Dec 01 22:55 trial.dll
-rw-rw-r--    1 John     John        107008 Dec 01 22:55 zlib.dll
C:/sbgcc/modules $ diff --help
BusyBox v1.26.0-FRP-811-g71ecc80 (2016-11-29 13:35:05 GMT) multi-call binary.

Usage: diff [-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2

Compare files line by line and output the differences between them.
This implementation supports unified diffs only.

        -a      Treat all files as text
        -b      Ignore changes in the amount of whitespace
        -B      Ignore changes whose lines are all blank
        -d      Try hard to find a smaller set of changes
        -i      Ignore case differences
        -L      Use LABEL instead of the filename in the unified header
        -N      Treat absent files as empty
        -q      Output only whether files differ
        -r      Recurse
        -S      Start with FILE when comparing directories
        -T      Make tabs line up by prefixing a tab when necessary
        -s      Report when two files are the same
        -t      Expand tabs to spaces in output
        -U      Output LINES lines of context
        -w      Ignore all whitespace
C:/sbgcc/modules $


I use vi, diff, grep, ... all the time when working in a console under Linux. The sh/bash shells are much better than using Windows batch files.



Title: Re: DLLC
Post by: JRS on December 08, 2016, 01:14:50 PM
TDM-GCC doesn't have the Linux configure script functionality and many libraries require it before the make process. I decided to install MinGW32  which includes mysy which acts like a Linux shell. I haven't tried recompiling my Script BASIC Windows 10 build with it yet and plan to use MinGW32 for library dependency builds or at least build the Makefile from the ./configure  and use TDM-GCC.

Strange to see such a difference in final execution size for these gcc Windows solutions.

MinGW-32 (msys)

John@Windows-10 /home/john
$ cat hello.c
#include <stdio.h>

int main(int argc, char **argv)
{
   printf ("Hello\n");
   return (0);
}

John@Windows-10 /home/john
$ gcc hello.c -o hello.exe

John@Windows-10 /home/john
$ hello
Hello

John@Windows-10 /home/john
$ ls -l hello.*
-rw-r--r-- 1 John Administrators   101 Dec  8 13:58 hello.c
-rwxr-xr-x 1 John Administrators 59634 Dec  8 14:01 hello.exe

John@Windows-10 /home/john


TDM-GCC-32 (busybox)

C:\TDM-GCC-32\test>busybox sh
C:/TDM-GCC-32/test $ cat hello.c
#include <stdio.h>

int main(int argc, char **argv)
{
   printf ("Hello\n");
   return (0);
}
C:/TDM-GCC-32/test $ gcc hello.c -o hello.exe
C:/TDM-GCC-32/test $ ls -l hello.*
-rw-rw-r--    1 John     John           101 Dec 08 13:58 hello.c
-rwxrwxr-x    1 John     John         27928 Dec 08 14:06 hello.exe
C:/TDM-GCC-32/test $ hello
Hello
C:/TDM-GCC-32/test $





.
Title: Re: DLLC
Post by: JRS on December 08, 2016, 08:11:50 PM
I now have a Makefile that compiles a Script BASIC build with all the extension modules I currently plan to include for Windows 10 32 bit.



.
Title: Re: DLLC
Post by: Mike Lobanovsky on December 08, 2016, 10:23:55 PM
Strange to see such a difference in final execution size for these gcc Windows solutions.

Sizes may vary greatly depending on the compiler/linker default switch settings which are different for the two distros. IIRC MinGW usually tends to create larger exes because it tries to link in alien (non-native to Windows) POSIX threads and SEH while TDM-GCC is on default substantially more system-friendly in this respect.

If you ever decide to try recompiling SB for x64 Windows, you may also consider J.C.Fuller's recommendation to try out nuwen (https://nuwen.net/mingw.html)'s custom recompilation of MinGW.
Title: Re: DLLC
Post by: JRS on December 09, 2016, 10:22:37 AM
I actually built a 64 bit TDM-GCC-64 version about a year ago. This is when I discovered how baron the Windows 64 bit world is.

I'm tryiing to build an Inno setup for Script BASIC Windows 32 bit. Hopefully more folks with give it a try if the install is automatic.

I decided not to use the math keyword enhancements added by Tom to scriba/sbhttpd. After looking at a diff of the mod, I noticed it shifted more than half of the SB keyword codes down by one. I plan on reworking the math additions as an extension module in an upcoming release.
Title: Re: DLLC
Post by: Charles Pegge on December 11, 2016, 02:53:15 AM

Hi John,

Here is the latest tested DLLC binary from the latest (11 December 2016) OxygenBasic.

No paths are specified, so there should be no problems with DLLC build, but you must copy it into the required location.

To run any JIT compiling you must put Oxygen.dll alonside dllc.dll. (modules folder)

.
Title: Re: DLLC
Post by: JRS on December 11, 2016, 08:15:46 PM
Thank you Charles!

DLLC compiled fine on Windows 10 without issue.

I will give DLLC some Windows 10 testing before including it in the Script BASIC for Windows (7-10) setup file I'm preparing.

It looks like I might be able to use Dave's IDE/Debugger as the featured GUI interface to Script BASIC on Windows 10.  The console mode scriba and Windows version of it, sbwin will also be included. I'm using Inno for the install setup file.
Title: Re: DLLC
Post by: JRS on December 18, 2016, 09:56:19 PM
I was going through some old code and discovered the DYC script that was the motivation for DLLC

Code: Script BASIC
  1. DECLARE SUB DLL ALIAS "dyc" LIB "dyc"
  2.  
  3. DLL "mc,i,iup.dll,IupOpen,PP",0,0
  4. win = DLL("mc,p,iup.dll,IupCreate,Z","dialog")
  5. lbl = DLL("mc,p,iup.dll,IupCreate,Z","label")
  6. DLL "mc,p,iup.dll,IupSetAttributes,PZ",lbl,"""
  7.  TITLE="Hello World!",
  8.  PADDING=100x75,
  9.  FONT="Arial, BOLD 24"
  10.  """
  11. DLL "mc,p,iup.dll,IupAppend,PP",win,lbl
  12. DLL "mc,i,iup.dll,IupShow,P",win
  13. DLL "mc,i,iup.dll,IupMainLoop,P",0
  14. DLL "mc,i,iup.dll,IupClose,P",0
  15.  





.
Title: Re: DLLC
Post by: JRS on December 20, 2016, 09:49:30 PM
Charles,

I'm getting ready to release a Script BASIC 2.2 Windows 32 bit setup install and I'm including a featured example program for each of the extension modules. DLLC can do so many things based on the notes in the code and the examples you have written. Can you create an example script that would feature DLLC's abilities? It would be much appreciated as I'm working on examples for the others.

John


Title: Re: DLLC
Post by: Charles Pegge on December 22, 2016, 01:35:33 AM
Hi John,

We have the DLLC test programs, which are, of course, very terse. Have you any specific in mind?

You made a nice IUP dialog, using DLLC. But I can no longer find it on my PC.
Title: Re: DLLC
Post by: JRS on December 22, 2016, 09:02:57 AM
Some of the key things I would like to see is how you can on the fly create a virtual DLL function, access/creation of data types and structures and low level COM. Showing some in-line ASM would be cool. I will cover multi-threading with the SBT ext. module. There are features of DLLC I still haven't gotten my arms around yet and hope you can clear things up.