Author Topic: DLLC  (Read 9031 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: DLLC
« Reply #15 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.
« Last Edit: November 14, 2016, 10:48:57 AM by John »

JRS

  • Guest
Re: DLLC
« Reply #16 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.  

Charles Pegge

  • Guest
Re: DLLC
« Reply #17 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.

JRS

  • Guest
Re: DLLC
« Reply #18 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.


Charles Pegge

  • Guest
Re: DLLC
« Reply #19 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);

JRS

  • Guest
Re: DLLC
« Reply #20 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.

« Last Edit: November 18, 2016, 02:26:01 AM by John »

Charles Pegge

  • Guest
Re: DLLC
« Reply #21 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 :)

JRS

  • Guest
Re: DLLC
« Reply #22 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.


« Last Edit: November 21, 2016, 08:48:57 PM by John »

JRS

  • Guest
Re: DLLC
« Reply #23 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.
« Last Edit: November 21, 2016, 11:26:42 AM by John »

Mike Lobanovsky

  • Guest
Re: DLLC
« Reply #24 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.

JRS

  • Guest
Re: DLLC
« Reply #25 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)
« Last Edit: November 21, 2016, 07:35:44 PM by John »

Charles Pegge

  • Guest
Re: DLLC
« Reply #26 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?
« Last Edit: November 23, 2016, 01:16:38 PM by Charles Pegge »

JRS

  • Guest
Re: DLLC
« Reply #27 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.

JRS

  • Guest
Re: DLLC
« Reply #28 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.


.

Mike Lobanovsky

  • Guest
Re: DLLC
« Reply #29 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. :)

.