Projeto CS-API:

1. Projeto CS-API:

???
gokernel

(usa Linux Mint)

Enviado em 05/07/2014 - 11:55h

Só divulgando o projeto BETA:

http://sourceforge.net/projects/cs-api/



WORDS:
-------------------------
int, float, struct;
print, for, if, break, function, return;
-------------------------

Para compilar leia o arquivo ( README.txt ).

BETA ...

<EDITADO>



  


2. Re: Projeto CS-API:

???
gokernel

(usa Linux Mint)

Enviado em 13/07/2014 - 11:01h

Projeto atualizado ( cs_1.0.0_BUILD_12.zip ):





WORDS:
-------------------------------------------------
int, float, struct,
print, for, if, break, function, return,
include, library, import,
char, asm, assembly;
-------------------------------------------------

DETALHE:
Apaguei alguns posts para evitar "poluição visual".

Caso alguém teste e encontre algum BUG, por gentileza favor me notifique ...

Um pequeno exemplo ( library, import ) usando SDL:

Esse programa sai ao clicar em algum quadrado ou ao teclar ESC.

Usando "C":


/*
**-------------------------------------------------------------------
**
** A simple example ( library, import ) using SDL
**
** FILE:
** sdl_pure.cs
**
** BY: Francisco G. A.
**
**-------------------------------------------------------------------
*/
library
"SDL" // Windows: SDL.dll
"libSDL" // Linux: libSDL.so
;

import
"SDL_Init"
"SDL_SetVideoMode"
"SDL_FillRect"
"SDL_Flip"
"SDL_PollEvent"
"SDL_Delay"
"SDL_Quit"
;

// sizeof(SDL_Event) = 20
//
struct Event {
char type; // used
char a;
char button; // mouse_button
char c;
short x, y; // mouse_x, mouse_y
int key; // used
};
struct Rect {
short x, y;
short w, h;
int color;
};
struct Rect rect[4]={
{ 100, 100, 100, 100, 63488 }, // color red
{ 400, 100, 100, 100, 2016 }, // color green
{ 100, 400, 100, 100, 31 }, // color blue
{ 400, 400, 100, 100, 64515 } // color orange
};
//-----------------------------------------------
//################# VARIABLES #################
//-----------------------------------------------
struct Event *ev; // sizeof: 20
struct Rect *r;
char *screen;
int i;
//-----------------------------------------------


function main()
{
SDL_Init (32);
screen = SDL_SetVideoMode (800, 600, 16, 0); // color 16

ev = malloc (25);

SDL_FillRect (screen, r, 1050); // NULL: bg full

// draw 4 box ( red, green, blue, orange ):
//
r = rect;
for(i=0;i<4;i++){
SDL_FillRect (screen, r, r->color);
r++;
}
SDL_Flip (screen);

printf ("\nTo exit of loop press the KEY ESCAPE\n\n");

//---------------------------------------------
//################ main loop ################
//---------------------------------------------
//
for(;;){

if (SDL_PollEvent(ev)) {

if (ev->type == 2) { // SDL_KEYDOWN
printf ("KEY: %d = (%c)\n", ev->key, ev->key);

// SDLK_ESCAPE = 27
//
if (ev->key == 27) { break; }
}

if (ev->type == 4) { //SDL_MOUSEMOTION
printf ("x: %d, y: %d\n", ev->x, ev->y);
}

//
// click in box ( red, green, blue, orange )
//
// !exit of loop:
//
if (ev->type == 5) { // SDL_MOUSEBUTTONDOWN
r = rect;
for(i=0;i<4;i++){
if (ev->x > r->x && ev->y > r->y && ev->x < r->x+r->w && ev->y < r->y+r->h) {
printf ("Cliking in rect[ %d ]\n", i);
asm ("jmp LABEL_LOOP_END");
}
r++;
}
}

}//: if (SDL_PollEvent(ev)) {

//<<<<<<<<<< HANDLE HERE >>>>>>>>>>

SDL_Delay(10);

}//: for(;;)

asm ("LABEL_LOOP_END:");

SDL_Quit();
}

main();
//code("main");




DETALHE:
Implementei/mudei as chamadas de funcoes ASM colocando um ( * ) no inicio da chamada ... motivo: para ficar mais rápida a compilação e evitar ficar procurando funcoes a todo tempo.
EXEMPLO:
----------------------------

asm ("*FuncName args");

----------------------------





3. Re: Projeto CS-API:

???
gokernel

(usa Linux Mint)

Enviado em 19/07/2014 - 12:30h


Projeto atualizado com a word ( OBJECT ):

OBS: A word ( OBJECT ) no momento só implementada para windows ... com foco em produtividade usando a FrameWork ( CAMPUS ) native windows, BETA ...

Um pequeno Exemplo:


/*
**-------------------------------------------------------------------
**
** A simple example using the Campus FrameWork (for Windows):
**
** FILE:
** campus_win32.cs
**
** BY: Francisco G. A.
**
**-------------------------------------------------------------------
*/
library "user32";
import
"ShowWindow"
"GetWindowTextA"
;

library "campus"; // campus.dll
import
"camInit"
"camRun"
"camNewWindow"
"camNewButton"
;

OBJECT
win,
button1,
button2
;

// alloc: 100
char *buf = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
int count;


//
// The generic callback button object:
//
function call_button (OBJECT o, int ev, int i)
{
GetWindowTextA (o,buf,90);

printf ("Text(%s) ev: %d, i: %d, count: %d\n", buf, ev, i, count);

count++;
}


function main()
{
camInit();

win = camNewWindow (
100,100,500,400, // x, y, w, h
0, // id
// flags: style = WS_OVERLAPPEDWINDOW: 13565952
//
13565952,
0, // parent
"Campus Framework test - BETA", // text,
0 // call
);

button1 = camNewButton (
100,100,150,50, // x, y, w, h
150, // id
// flags: style = WS_VISIBLE | WS_CHILD: 1342177280
//
1342177280,
win, // parent
"Button id(150)", // text,
call_button // call
);

button2 = camNewButton (
100,200,150,50, // x, y, w, h
200, // id
// flags: style = WS_VISIBLE | WS_CHILD: 1342177280
//
1342177280,
win, // parent
"BUTTON ID(200)", // text,
call_button // call
);


ShowWindow (win,1);
// ShowWindow (button1,1);
// ShowWindow (button2,1);

camRun();
}

main();










Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts