Basic programming language :: thinBasic Community
September 10, 2010, 10:16:09 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: RobotDuel - Game for 2 players: http://community.thinbasic.com/index.php?topic=305.0
 
  Home Help thinGaming Search Calendar Gallery Articles Donations Tags Media Center Login Register   *

thinBasic 1.8.0.0 is out !  :: See this post ( last update: 2010.03.07 ! )  :: Latest beta version: thinBasic beta 1.8.6.0 ( last update: 2010.08.02 ! )
Main menu
Members
Total Members: 526
Latest: jnash67
Stats
Total Posts: 26734
Total Topics: 3548
Online Today: 31
Online Ever: 121
(August 16, 2009, 07:08:32 am)
Users Online
Users: 0
Guests: 12
Total: 12
1 Spider, 12 Guests, 0 Users

MSN spider
Subject Statistics
Topic: Interpreter inside a database Replies: 15 posts
Read 617 times 0 Members and 1 Guest are viewing this topic.
Pages: 1 2 
  Add bookmark  |  Print  
Author Topic: Interpreter inside a database  (Read 617 times)
0 Members and 1 Guest are viewing this topic.
Charles Pegge
Sr. Member
****

Karma: 34
Offline

Posts: 934


OS:
Windows Vista Windows Vista
Browser:
Chrome 4.0.249.78 Chrome 4.0.249.78


WWW
« Reply #15 on: February 08, 2010, 11:15:36 pm »

With Basic Prototype Declarations, double-pointered variables etc get messed up and you have to degrade them to dwords. This is because Basic does not support the typedef constructs found in C. So translating C headers to Basic headers will require considerable interpretation, which is why I aim to read C header files directly.

Now for interfacing APIs at a lower level, all the compiler needs to know is the library handle, and a list comprising pairs of alias names and real case-sensitive names for each call available. No type matching is attempted - so you have to know what you are providing is compatible with the library call - for instance it is ok to provide a dword when a byte is expected. And you must explicitly pass the variable's adress when a pointer is expected.

This is an example of low level API declaration in Oxygen (the semicolons are comment marks)

Code
  dim kernel32,user32,GDI32 as long
 kernel32=LoadLibrary `kernel32.dll`
 user32=LoadLibrary `user32.dll`
 GDI32=LoadLibrary `GDI32.dll`
 
 bind kernel32
 (
   GetCommandLine  GetCommandLineA   ; @0
   GetModuleHandle GetModuleHandleA  ; @4
   ExitProcess     ExitProcess       ; @4
 )
 
 bind user32
 (
   LoadIcon         LoadIconA         ; @8
   LoadCursor       LoadCursorA       ; @8
   RegisterClass    RegisterClassA    ; @4
   MessageBox       MessageBoxA       ; @4
   CreateWindowEx   CreateWindowExA   ; @48
   ShowWindow       ShowWindow        ; @8
   UpdateWindow     UpdateWindow      ; @4
   GetMessage       GetMessageA       ; @16
   TranslateMessage TranslateMessage  ; @4
   DispatchMessage  DispatchMessageA  ; @4
   PostQuitMessage  PostQuitMessage   ; @4
   BeginPaint       BeginPaint        ; @8
   EndPaint         EndPaint          ; @8
   GetClientRect    GetClientRect     ; @8  
   DrawText         DrawTextA         ; @20
   PostMessage      PostMessageA      ; @16
   DefWindowProc    DefWindowProcA    ; @16
 )
 
 
 bind GDI32
 (
   SetBkColor       SetBkColor        ; @16
   SetTextColor     SetTextColor      ; @16
   GetStockObject   GetStockObject    ; @4
 )
 

Logged

Tags:
Pages: 1 2 
  Add bookmark  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!


Google visited last this page August 26, 2010, 04:23:11 pm