2 single: What is new in Ring 1.7?; Introduction
4 ========================
5 What is new in Ring 1.7?
6 ========================
8 In this chapter we will learn about the changes and new features in Ring 1.7 release.
11 pair: What is new in Ring 1.7?; List of changes and new features
13 List of changes and new features
14 ================================
16 Ring 1.7 comes with many new features!
18 * New Command: Load Package
19 * ringvm_see() and ringvm_give() functions
20 * ring_state_new() and ring_state_mainfile() functions
21 * Better Trace Library
26 * Better Documentation
32 pair: What is new in Ring 1.7?; New Command: Load Package
34 New Command: Load Package
35 =========================
37 Using the 'load' command we can use many ring source files in the same project
39 But all of these files will share the same global scope
41 Now we have the "Load Package" command too
43 Using "Load Package" we can load a library (*.ring file) in new global scope
45 This is very useful to create libraries that avoid conflicts in global variables
49 File: loadpackage.ring
55 load package "testloadpackage.ring"
60 File: testloadpackage.ring
64 ? "Hello from testloadpackage.ring"
78 Hello from testloadpackage.ring
86 pair: What is new in Ring 1.7?; ringvm_see() and ringvm_give() functions
88 ringvm_see() and ringvm_give() functions
89 ========================================
91 Using the ringvm_see() function we can redefine the behavior of the See command
93 Also we can use ring_see() to have the original behavior
99 see "Hello world" + nl
101 see ["one","two","three"]
102 see new point {x=10 y=20 z=30}
105 ring_see("We want to print: ")
114 We want to print: Hello world
115 We want to print: 123
116 We want to print: one
119 We want to print: x: 10.000000
123 Using the ringvm_give() function we can redefine the behavior of the Give command
125 Also we can use ring_give() to have the original behavior
131 see "Name: " give name
146 pair: What is new in Ring 1.7?; ring_state_new() and ring_state_mainfile() functions
148 ring_state_new() and ring_state_mainfile() functions
149 ====================================================
151 Using ring_state_new() and ring_state_mainfile() we can run Ring programs from Ring programs
153 But unlike ring_state_main(), Here we can control when to delete the Ring state!
155 This is important when we run GUI programs from GUI programs
157 Because they will share the GUI Library (RingQt), And In this case the caller will call
161 So the sub program, will not stop and will return to the Main program
163 Here deleting the State of the sub programs will lead to a problem when we run the sub program events
165 So keeping the state is important for sub GUI programs hosted in GUI programs.
169 pair: What is new in Ring 1.7?; Better Trace Library
174 The Trace library is updated, In the Debugger at break points we have now the "callstack" command
176 This command will print the functions call stack.
189 ? "Hello from test1!"
193 ? "Hello from test2!"
197 ? "Hello from test3!"
201 .. image:: callstack.png
205 pair: What is new in Ring 1.7?; Better Ring Notepad
210 Ring Notepad comes with the next updates
212 (1) Support *.cf extension
213 (2) Using Hash function (SHA256) for better "Save Changes?" message
214 (3) Ring Notepad - X Button - Ask for saving changes?
218 pair: What is new in Ring 1.7?; Better RingQt
223 The next classes are added to RingQt
231 (7) QOpenGLVersionProfile
232 (8) QOpenGLFunctions_3_2_Core
238 (14) QOpenGLPaintDevice
240 (16) QOpenGLTimerQuery
241 (17) QOpenGLDebugLogger
242 (18) QOpenGLFramebufferObject
243 (19) QOpenGLVertexArrayObject
245 (21) QOpenGLShaderProgram
250 pair: What is new in Ring 1.7?; Better Ring2EXE
255 Ring2EXE is updated to works as expected when we don't have a C/C++ compiler
257 Where we can distribute applications and get (exe file and ringo file) in this case.
261 pair: What is new in Ring 1.7?; Better RingZip
266 The library is updated to support extracting files contains sub folders!
269 pair: What is new in Ring 1.7?; Better Documentation
274 (1) RingQt Classes Chapter - The classes are sorted.
278 pair: What is new in Ring 1.7?; Better Ring VM
283 (1) Better Error Message
284 (2) List2Str() function support lists contains numbers
285 (3) Correct support for numbers contains _ as separator
286 (4) Creating lists without variables (statement --> Expression --> List)
287 (5) IsNULL() - Not case sensitive - treat Null and null like NULL
288 (6) Support adding the Self object to an attribute in this object
289 (7) Using ':' operator then keyword will create lower case literal
290 (8) Printing objects - respect decimals() function
291 (9) When literal is not closed - determine the start of the literal
292 (10) Better message when printing objects contains lists
293 (11) VarPtr() - Support getting a pointer to variables in the local scope
294 (12) replace performance instructions with normal instructions when creating new threads
297 pair: What is new in Ring 1.7?; RingLibuv Extension
302 Ring 1.7 comes with the RingLibuv extension
304 Libuv is a multi-platform support library with a focus on asynchronous I/O.
306 Example (Events Loop):
316 idler = new_uv_idle_t()
317 uv_idle_init(uv_default_loop(), idler)
318 uv_idle_start(idler, "wait()")
320 uv_run(uv_default_loop(), UV_RUN_DEFAULT);
321 uv_loop_close(uv_default_loop());
322 destroy_uv_idle_t(idler)
341 load "objectslib.ring"
343 ? "Testing RingLibuv - Server Side - Using Classes"
345 open_object(:MyServer)
347 class MyServer from ObjectControllerParent
350 DEFAULT_BACKLOG = 1024
352 addr = new_sockaddr_in()
358 myloop = uv_default_loop()
359 server = new_uv_tcp_t()
360 uv_tcp_init(myloop, server)
361 uv_ip4_addr("127.0.0.1", DEFAULT_PORT, addr)
362 uv_tcp_bind(server, addr, 0)
363 r = uv_listen(server, DEFAULT_BACKLOG, Method(:newconnection) )
365 ? "Listen error " + uv_strerror(r)
368 uv_run(myloop, UV_RUN_DEFAULT)
369 destroy_uv_tcp_t(server)
370 destroy_uv_sockaddr_in(addr)
374 aPara = uv_Eventpara(server,:connect)
377 ? "New connection error : " + nStatus
380 client = new_uv_tcp_t()
381 uv_tcp_init(myloop, client)
382 if uv_accept(server, client) = 0
383 uv_read_start(client, uv_myalloccallback(),
388 aPara = uv_Eventpara(client,:read)
392 req = new_uv_write_t()
393 wrbuf = uv_buf_init(get_uv_buf_t_base(buf), nread)
394 uv_write(req, client, wrbuf, 1, Method(:echo_write))
396 message = "message from the server to the client"
398 set_uv_buf_t_len(buf,len(message))
399 set_uv_buf_t_base(buf,varptr("message","char *"))
400 uv_write(req, client, buf, 1, Method(:echo_write))
404 aPara = uv_Eventpara(client,:read)
410 When we run the client, We will see the message "New Connection"
412 Then the message "hello from the client"
416 Testing RingLibuv - Server Side - Using Classes
418 hello from the client
420 Example (Using Threads):
425 load "objectslib.ring"
427 ? "Testing RingLibuv - Threads - Using Classes"
429 open_object(:MyThreads)
431 class MyThreads from ObjectControllerParent
434 one_id = new_uv_thread_t()
435 two_id = new_uv_thread_t()
436 uv_thread_create(one_id, Method(:One))
437 uv_thread_create(two_id, Method(:Two))
438 uv_thread_join(one_id)
439 uv_thread_join(two_id)
440 destroy_uv_thread_t(one_id)
441 destroy_uv_thread_t(two_id)
444 ? "Message from the First Thread!"
447 ? "Message from the Second Thread!"
454 Testing RingLibuv - Threads - Using Classes
455 Message from the First Thread!
456 Message from the Second Thread!
458 For more information about this extension (RingLibuv) check the chapter: Using RingLibuv