Enviar búsqueda
Cargar
Lua by Ong Hean Kuan
•
Descargar como ODP, PDF
•
5 recomendaciones
•
1,297 vistas
F
fossmy
Seguir
Presented at the MyOSS March 2009 Meetup
Leer menos
Leer más
Tecnología
Denunciar
Compartir
Denunciar
Compartir
1 de 23
Descargar ahora
Recomendados
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
SHAMJITH KM
Python basic
Python basic
Saifuddin Kaijar
Python ppt
Python ppt
Anush verma
Introduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIML
VijaySharma802
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
Ch8a
Ch8a
kinnarshah8888
Python Basics
Python Basics
Adheetha O. V
Python ppt
Python ppt
Rohit Verma
Recomendados
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
SHAMJITH KM
Python basic
Python basic
Saifuddin Kaijar
Python ppt
Python ppt
Anush verma
Introduction to Python Programming | InsideAIML
Introduction to Python Programming | InsideAIML
VijaySharma802
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
Utkarsh Sengar
Ch8a
Ch8a
kinnarshah8888
Python Basics
Python Basics
Adheetha O. V
Python ppt
Python ppt
Rohit Verma
Shell programming 2
Shell programming 2
Gourav Varma
Shell programming 2
Shell programming 2
Kalkey
Rust Intro
Rust Intro
Arthur Gavkaluk
Introduction to Python Programming
Introduction to Python Programming
VijaySharma802
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
Symbolic mathematics
Symbolic mathematics
FranklinChibuike1
Python Basics
Python Basics
Pooja B S
python.ppt
python.ppt
shreyas_test_1234
Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
Python basics
Python basics
NexThoughts Technologies
Python programing
Python programing
hamzagame
C Programming Homework Help
C Programming Homework Help
Programming Homework Help
Introduction to Python - Part Two
Introduction to Python - Part Two
amiable_indian
Introduction to Python
Introduction to Python
C. ASWINI
Introduction to Python - Training for Kids
Introduction to Python - Training for Kids
Aimee Maree Forsstrom
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
PPT on Data Science Using Python
PPT on Data Science Using Python
NishantKumar1179
An Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
Python advance
Python advance
Deepak Chandella
E6
E6
lksoo
High Level Application Scripting With EFL and LuaJIT
High Level Application Scripting With EFL and LuaJIT
Samsung Open Source Group
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT intro
igdshare
Más contenido relacionado
La actualidad más candente
Shell programming 2
Shell programming 2
Gourav Varma
Shell programming 2
Shell programming 2
Kalkey
Rust Intro
Rust Intro
Arthur Gavkaluk
Introduction to Python Programming
Introduction to Python Programming
VijaySharma802
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
Symbolic mathematics
Symbolic mathematics
FranklinChibuike1
Python Basics
Python Basics
Pooja B S
python.ppt
python.ppt
shreyas_test_1234
Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
Python basics
Python basics
NexThoughts Technologies
Python programing
Python programing
hamzagame
C Programming Homework Help
C Programming Homework Help
Programming Homework Help
Introduction to Python - Part Two
Introduction to Python - Part Two
amiable_indian
Introduction to Python
Introduction to Python
C. ASWINI
Introduction to Python - Training for Kids
Introduction to Python - Training for Kids
Aimee Maree Forsstrom
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
PPT on Data Science Using Python
PPT on Data Science Using Python
NishantKumar1179
An Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Sumit Raj
Python advance
Python advance
Deepak Chandella
E6
E6
lksoo
La actualidad más candente
(20)
Shell programming 2
Shell programming 2
Shell programming 2
Shell programming 2
Rust Intro
Rust Intro
Introduction to Python Programming
Introduction to Python Programming
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Symbolic mathematics
Symbolic mathematics
Python Basics
Python Basics
python.ppt
python.ppt
Python in 30 minutes!
Python in 30 minutes!
Python basics
Python basics
Python programing
Python programing
C Programming Homework Help
C Programming Homework Help
Introduction to Python - Part Two
Introduction to Python - Part Two
Introduction to Python
Introduction to Python
Introduction to Python - Training for Kids
Introduction to Python - Training for Kids
Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
PPT on Data Science Using Python
PPT on Data Science Using Python
An Intro to Python in 30 minutes
An Intro to Python in 30 minutes
Python advance
Python advance
E6
E6
Destacado
High Level Application Scripting With EFL and LuaJIT
High Level Application Scripting With EFL and LuaJIT
Samsung Open Source Group
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT intro
igdshare
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
Hisham Muhammad
Api Design Anti-Patterns
Api Design Anti-Patterns
Jason Harmon
Hands on lua
Hands on lua
Javier Arauz
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
Jon Moore
Accounting concepts conventions & principles
Accounting concepts conventions & principles
Jatin Pancholi
Destacado
(7)
High Level Application Scripting With EFL and LuaJIT
High Level Application Scripting With EFL and LuaJIT
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT intro
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
What's New in LuaRocks - Lua Workshop 2014 - Hisham Muhammad
Api Design Anti-Patterns
Api Design Anti-Patterns
Hands on lua
Hands on lua
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
Accounting concepts conventions & principles
Accounting concepts conventions & principles
Similar a Lua by Ong Hean Kuan
Programming Under Linux In Python
Programming Under Linux In Python
Marwan Osman
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
Eleanor McHugh
Python
Python
Gagandeep Nanda
Python slide
Python slide
Kiattisak Anoochitarom
C
C
arunsahoo90
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
Use of Lua in Lab Devices
Use of Lua in Lab Devices
Claus Kühnel
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
Eleanor McHugh
Introduction to python
Introduction to python
baabtra.com - No. 1 supplier of quality freshers
lecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
C to perl binding
C to perl binding
Shmuel Fomberg
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
climatewarrior
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
ezonesolutions
Programming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptx
SONU KUMAR
Hands on Session on Python
Hands on Session on Python
Sumit Raj
C programming
C programming
Shahariar limon
C tutorial
C tutorial
tuncay123
C tutorial
C tutorial
Khan Rahimeen
C tutorial
C tutorial
Anuja Lad
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
GDSCVJTI
Similar a Lua by Ong Hean Kuan
(20)
Programming Under Linux In Python
Programming Under Linux In Python
Implementing Virtual Machines in Ruby & C
Implementing Virtual Machines in Ruby & C
Python
Python
Python slide
Python slide
C
C
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Use of Lua in Lab Devices
Use of Lua in Lab Devices
Implementing Virtual Machines in Go & C
Implementing Virtual Machines in Go & C
Introduction to python
Introduction to python
lecture 2.pptx
lecture 2.pptx
C to perl binding
C to perl binding
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
Programming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptx
Hands on Session on Python
Hands on Session on Python
C programming
C programming
C tutorial
C tutorial
C tutorial
C tutorial
C tutorial
C tutorial
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
Último
Training state-of-the-art general text embedding
Training state-of-the-art general text embedding
Zilliz
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
DianaGray10
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
Lonnie McRorey
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Fwdays
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Sergiu Bodiu
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
LoriGlavin3
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
mohitsingh558521
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
Lars Bell
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
UiPathCommunity
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
BkGupta21
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Dilum Bandara
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
LoriGlavin3
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
Nicole Novielli
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
LoriGlavin3
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
BookNet Canada
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
LoriGlavin3
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
Raghuram Pandurangan
Último
(20)
Training state-of-the-art general text embedding
Training state-of-the-art general text embedding
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
Lua by Ong Hean Kuan
1.
Extending C/C++ with
Lua 5.1 Ong Hean Kuan Unified Communications Email: mysurface@gmail.com
2.
3.
4.
5.
6.
Fast and Lightweight?
7.
8.
Performance ~ Benchmarking
2
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
Simple c++ calling
lua script extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" } int main() { int s=0; lua_State *L = lua_open(); // load the libs luaL_openlibs(L); //run a Lua scrip here luaL_dofile(L,"foo.lua"); printf("I am done with Lua in C++."); lua_close(L); return 0; } -- foo.lua io.write(“Happy Hacking with Lua”) g++ -o simple{,.cc} -llua -ldl
19.
Accessing Lua global
variables int width=0,height=0; lua_State *L = lua_open(); luaL_openlibs(L); if (luaL_loadfile(L, "config.lua") || lua_pcall(L, 0, 0, 0)) printf("error: %s", lua_tostring(L, -1)); lua_getglobal(L, "width"); lua_getglobal(L, "height"); if (!lua_isnumber(L, -2)) { printf ("`width' should be a number"); return -1; } if (!lua_isnumber(L, -1)) { printf("`height' should be a number"); return -1; } width = (int)lua_tonumber(L, -2); height = (int)lua_tonumber(L, -1); printf("width: %dheight: %d", width, height); lua_close(L); return 0; -- config.lua width = 10 height = 5
20.
Calling c from
Lua int L_MSleep(lua_State* l) { int milisec=0; struct timespec req={0}; time_t sec; milisec=luaL_optint(l,1,0); if (milisec==0) return 0; sec=(int)(milisec/1000); milisec=milisec-(sec*1000); req.tv_sec=sec; req.tv_nsec=milisec*1000000L; while(nanosleep(&req,&req)==-1) continue; return 1; } int main() { const static struct luaL_reg misc [] = { {"msleep", &L_MSleep}, {NULL,NULL} //must! }; lua_State *L = lua_open(); luaL_openlibs(L); //open your lib luaL_openlib(L, "misc", misc, 0); if (luaL_loadfile(L, "callc.lua") || lua_pcall(L, 0, 0, 0)) printf("error: %s", lua_tostring(L, -1)); lua_close(L); return 0; } -- callc.lua for i=1,9,1 do io.write(string.format("[%d] Hello",i)) misc.msleep(1000) -- sleep 1 sec end
21.
Calling Lua from
c int main() { double z; lua_State *L = lua_open(); luaL_openlibs(L); if (luaL_loadfile(L, "last.lua") || lua_pcall(L, 0, 0, 0)) { printf("error: %s", lua_tostring(L, -1)); return -1; } lua_getglobal(L, "f"); lua_pushnumber(L, 2); /* push 1st argument */ lua_pushnumber(L, 3); /* push 2nd argument */ /* do the call (2 arguments, 1 result) */ if (lua_pcall(L, 2, 1, 0) != 0) { printf("error running function `f': %s",lua_tostring(L, -1)); return -1; } /* retrieve result */ if (!lua_isnumber(L, -1)) { printf("function `f' must return a number"); return -1; } z = lua_tonumber(L, -1); printf("Result: %f",z); lua_pop(L, 1); lua_close(L); return 0; } -- last.lua function f (x, y) return (x^2 * math.sin(y))/(1 - x) end
22.
23.
Thank you ;)
Descargar ahora