Attempting to subscript an atom Error[SOLVED]

new topic     » topic index » view thread      » older message » newer message

Hello all,

When trying to wrap the add-on functions for Allegro, I came across this error: Attempting to subscript an atom

I posted the code from where the error is coming from. Let me know if more code is needed. I am using the FFI.e I'm not sure why I would get that error as it just returning a boolean variable.

Wrapper code

include std/ffi.e 
 
include allegro.e 
 
export constant prim = open_dll("allegro_primitives-5.2"), --this needed to have .dll added to the end 
 
				xal_get_allegro_primitives_version = define_c_func(prim,"al_get_allegro_primitives_version",{},C_UINT) --this was missing a "+" 
				 
public function al_get_allegro_primitives_version() 
	return c_func(xal_get_allegro_primitives_version,{}) 
end function 
 
 
export constant xal_init_primitives_addon = define_c_func(prim,"+al_init_primitives_addon",{},C_BOOL), 
				xal_is_primitives_addon_initialized = define_c_func(prim,"+al_is_primitives_addon_initialized",{},C_BOOL), 
				xal_shutdown_primitives_addon = define_c_proc(prim,"+al_shutdown_primitives_addon",{}), 
				xal_draw_prim = define_c_func(prim,"+al_draw_prim",{C_POINTER,C_POINTER,C_POINTER,C_INT,C_INT,C_INT},C_INT), 
				xal_draw_indexed_prim = define_c_func(prim,"+al_draw_indexed_prim",{C_POINTER,C_POINTER,C_POINTER,C_POINTER,C_INT,C_INT},C_INT), 
				xal_draw_vertex_buffer = define_c_func(prim,"+al_draw_vertex_buffer",{C_POINTER,C_POINTER,C_INT,C_INT,C_INT},C_INT), 
				xal_draw_indexed_buffer = define_c_func(prim,"+al_draw_indexed_buffer",{C_POINTER,C_POINTER,C_POINTER,C_INT,C_INT,C_INT},C_INT) 
				 
public function al_init_primitives_addon() 
	return c_func(xal_init_primitives_addon,{}) --error is coming from this line 
end function 
 
public function al_is_primitives_addon_initialized() 
	return c_func(xal_is_primitives_addon_initialized,{}) 
end function 
 
public procedure al_shutdown_primitives_addon() 
	c_proc(xal_shutdown_primitives_addon,{}) 
end procedure 

Demo program

--Simple Display Window demo 
--Draw primitive shapes 
 
include allegro.e 
include keycodes.e 
include std/ffi.e 
 
include primitives.e 
 
procedure main() 
 
 atom x = al_install_system(ALLEGRO_VERSION_INT,0) 
  
 atom a = al_init_primitives_addon() 
  
 if x = -1 then 
 	puts(1,"Failed to init Allegro!\n") 
 	abort(0) 
 end if 
  
 if a = -1 then 
 	puts(1,"Failed to init addon!\n") 
 	abort(0) 
 end if 
  
 atom dis = al_create_display(800,600) 
  
 if dis = -1 then 
 	puts(1,"Failed to create display!\n") 
 	abort(0) 
 end if 
  
 al_set_window_title(dis,"Primitive Demo") 
  
 sequence BLUE = al_map_rgb(0,0,255) 
 
 al_draw_line(10,10,10,10,BLUE,10)  
 
 al_flip_display() 
   
 al_rest(5.0) 
  
 al_destroy_display(dis) 
	 
end procedure 
 
main() 
 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu