显示标签为“lua”的博文。显示所有博文
显示标签为“lua”的博文。显示所有博文

星期日, 十一月 23, 2008

lighttpd-1.5.0-r1992-native.win32.zip

一直在等lighttpd for win32的发布,终于1.5.0版本中对于Win32的支持已经考虑在内了,但是官方版本是没有推出可以直接在MSVC中编译的工程,因为着急,所以自己改了一个,喜欢研究的朋友可以从这里下载一试!支持Lua!

下载   http://cid-93488dd0cf5117e9.skydrive.live.com/self.aspx/Public/lighttpd-1.5.0-r1992-native.win32.zip

星期五, 二月 02, 2007

gcc的语法检查

在编译mod_lua 0.5的过程中,下面的代码出现警告
LuaState *L;
void** data = (void**) &L;
warning: dereferencing type-punned pointer will break strict-aliasing rules

-------------
gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)


somebody say that:

Yes, by implying -fstrict-aliasing, so using -fno-strict-aliasing is a
workaround. The problem is caused by the i386 PCPU_GET/PCPU_SET
implementation:

#define __PCPU_GET(name) ({ \
__pcpu_type(name) __result; \
\
[...]
} else if (sizeof(__result) == 4) { \
u_int __i; \
__asm __volatile("movl %%fs:%1,%0" \
: "=r" (__i) \
: "m" (*(u_int *)(__pcpu_offset(name)))); \
__result = *(__pcpu_type(name) *)&__i; \
[...]

In this case, the PCPU_GET is used to retrieve curthread, causing
sizeof(__result) to be 4, so the cast at the end of the code snippet
is from a u_int * to struct thread *, and __i is accessed through the
casted pointer, which violates the C99 aliasing rules.
An alternative is to type-pun via a union, which is also a bit ugly,
but explicitly allowed by C99. Patch attached (but only superficially
tested).

mod_lua 0.5终于发布了

在mod_lua 0.5上已经花费好大精力了,在经过一番修改与测试之后,在http://mod-lua.sourceforge.net上发布了这个版本,继续其它的工作! 

星期四, 十二月 21, 2006

几种Apache CGI模块性能简单分析比较 被不带出处转载

今天, 在网上搜索LUA的相关信息,发现自己blog里面的 几种Apache CGI模块性能简单分析比较 在
http://www.mylinux.com.cn/newsTextAction.do?id=15,045 处出现,进去看了一下,居然连转载申明也没有,这样的编辑还真的能搞!

星期二, 十月 10, 2006

mod_lua性能提升,是mod_python速度115%

在上次的性能对比之后,忍不住对mod_lua的程序作了改进,下面是最新的测试结果

mod_python
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: 80

Document Path: /tmp/hello.py
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 1.78125 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 102500 bytes
HTML transferred: 6000 bytes
Requests per second: 463.77 [#/sec] (mean)
Time per request: 2.156 [ms] (mean)
Time per request: 2.156 [ms] (mean, across all concurrent requests)
Transfer rate: 92.75 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.3 0 15
Processing: 0 1 4.7 0 15
Waiting: 0 1 4.5 0 15
Total: 0 1 5.1 0 15

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 15
95% 15
98% 15
99% 15
100% 15 (longest request)
mod_lua
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: 80

Document Path: /tmp/hello.lua
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 0.937500 seconds
Complete requests: 500
Failed requests: 0
Write errors: 0
Total transferred: 102000 bytes
HTML transferred: 6000 bytes
Requests per second: 533.33 [#/sec] (mean)
Time per request: 1.875 [ms] (mean)
Time per request: 1.875 [ms] (mean, across all concurrent requests)
Transfer rate: 105.60 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.2 0 15
Processing: 0 1 4.2 0 15
Waiting: 0 1 4.1 0 15
Total: 0 1 4.7 0 15

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 15
95% 15
98% 15
99% 15
100% 15 (longest request)
这次修改可谓全胜
速度比如下每秒处理的请求 463.77/533.33(mod_python/mod_lua)
每个请求处理花费的时间微妙: 2.156/1.875(mod_python/mod_lua)

性能提升的原因说明:

1 mod_lua从串行处理方式改成并行处理方式
2 lua虚拟机采用了空闲池处理

星期六, 十月 07, 2006

编成语言性能评测

Ruby, Io, PHP, Python, Lua, Java, Haskell, and Plain C Fractal Benchmark

http://www.timestretch.com/FractalBenchmark.html

compare python vs lua, ruby, PHP and Haskell

http://william-os4y.livejournal.com/2216.html


 

星期五, 十月 06, 2006

几种Apache CGI模块性能简单分析比较

最近对  mod_python, mod_php, mod_ruby, mod_lua做一个简单的性能比较,目的是想知道mod_lua在性能方面该如何改进!

工作在Windows 2003, VS 2005下完成,全部采用动态编译
-
mod_python已被捐赈给apache由apache关方维护,轻松搞定(支持python 2.4,不支持python2.5)
mod_php 一直被作为CGI开发的热点,也非常容易搞定
mod_lua 是本人的开源项目,自然不用碰到问题(支持最新lua 5.1.1)
mod_ruby 这个小日本的东西,在他上面花的时间最多, 首先与yarv(ruby 2.0)还不兼容,另外在ruby 1.8.5的编译时候需要在程序内部切换一个宏,另外还有个内存问题! 文档资料也很少.(mod_lua根本还没有文档,我以后会陆续给出)!需要一定的经验,不能自动完成.

( 就我对apache与ruby的了解程度自信可以搞定, 对于小日本开源软件的态度还真不敢恭维,ROR不知是被那位炒起来的, 反正mod_ruby的性能不敢恭维.)

---PHP的测试
页面
echo "Hello World!";
命令行
ab -n 100 http://localhost/tmp/hello.php

输出结果
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: ; &nbsp; 80

Document Path: &nbsp; ; /tmp/hello.php
Document Length: 12 bytes

Concurrency Level: &nbsp; &nbsp; 1

Time taken for tests: 0.609375 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 28700 bytes
HTML transferred: 1200 bytes
Requests per second: 164.10 [#/sec] (mean)
Time per request: 6.094 [ms] (mean)
Time per request: 6.094 [ms] (mean, across all concurrent requests)
Transfer rate: 45.95 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.1 0 15
Processing: 0 4 7.2 0 15
Waiting: 0 4 7.1 0 15
Total: 0 5 7.2 0 15

Percentage of the requests served within a certain time (ms)
50% 0
66% 15
75% 15
80% 15
90% 15
95% 15
98% 15
99% 15
100% 15 (longest request)

------mod_pythonde的测试
页面
from mod_python import apache

def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK
命令行
ab -n 100 http://localhost/tmp/hello.py
输出结果
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.nutstech.com (be patient).....done


Server Software: Apache/2.0.59
Server Hostname: www.nutstech.com
Server Port: 80

Document Path: /tmp/hello.py
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 0.359375 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 20500 bytes
HTML transferred: 1200 bytes
Requests per second: 278.26 [#/sec] (mean)
Time per request: 3.594 [ms] (mean)
Time per request: 3.594 [ms] (mean, across all concurrent requests)
Transfer rate: 55.65 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.6 0 15
Processing: 0 2 5.7 0 15
Waiting: 0 2 5.2 0 15
Total: 0 3 6.0 0 15

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 15
90% 15
95% 15
98% 15
99% 15
100% 15 (longest request)

-----mod_lua的测试
页面程序
http.print("Hello World!")
命令行
ab -n 100 http://localhost/tmp/hello.lua
测试结果
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: 80

Document Path: /tmp/hello.lua
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 0.468750 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 24200 bytes
HTML transferred: 1200 bytes
Requests per second: 213.33 [#/sec] (mean)
Time per request: 4.688 [ms] (mean)
Time per request: 4.688 [ms] (mean, across all concurrent requests)
Transfer rate: 49.07 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.6 0 15
Processing: 0 3 6.6 0 31
Waiting: 0 2 6.0 0 15
Total: 0 3 6.9 0 31

Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 15
90% 15
95% 15
98% 15
99% 31
100% 31 (longest request)

----mod_ruby的测试
页面
#!/usr/bin/ruby

require "cgi"

cgi = CGI.new
print cgi.header("type"=>"text/plain")
print "Hello World!"


命令
ab -n 100 http://localhost/tmp/hello.rbx
测试结果
 This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: 80

Document Path: /tmp/hello.rbx
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 1.187500 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 24300 bytes
HTML transferred: 1200 bytes
Requests per second: 84.21 [#/sec] (mean)
Time per request: 11.875 [ms] (mean)
Time per request: 11.875 [ms] (mean, across all concurrent requests)
Transfer rate: 19.37 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.1 0 15
Processing: 0 10 9.1 15 46
Waiting: 0 9 9.1 15 46
Total: 0 10 9.1 15 46

Percentage of the requests served within a certain time (ms)
50% 15
66% 15
75% 15
80% 15
90% 15
95% 31
98% 31
99% 46
100% 46 (longest request)

This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software: Apache/2.0.59
Server Hostname: localhost
Server Port: 80

Document Path: /tmp/hello.rbx
Document Length: 12 bytes

Concurrency Level: 1
Time taken for tests: 1.187500 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Total transferred: 24300 bytes
HTML transferred: 1200 bytes
Requests per second: 84.21 [#/sec] (mean)
Time per request: 11.875 [ms] (mean)
Time per request: 11.875 [ms] (mean, across all concurrent requests)
Transfer rate: 19.37 [Kbytes/sec] received


Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.1 0 15
Processing: 0 10 9.1 15 46
Waiting: 0 9 9.1 15 46
Total: 0 10 9.1 15 46

Percentage of the requests served within a certain time (ms)
50% 15
66% 15
75% 15
80% 15
90% 15
95% 31
98% 31
99% 46
100% 46 (longest request)



结果比较:


  • 模块名称 结果(次/秒)
  • mod_python 278.26
  • mod_lua 213.33
  • mod_php 164.10
  • mod_ruby 84.21
mod_python的处理速度果然快, 难怪google实用了很多的python, 不要犹豫, 用python吧!
当然php在WEB开发中的地位已经巩固, 但我相信很快就会被python赶上并超越
我开发的mod_lua,是为嵌入式应用准备的,在执行速度与模块大小方面都不错!且可直接用共享内存来通信 具体大家可以到 http://sf.net/projects/modlua 去了解!
mod_ruby是在是不敢恭维,如果采用eruby估计会更慢,将用ruby开发web的人,需要仔细考虑了


星期三, 十月 04, 2006

从微尘《一个Python程序的6次改进》想到的

一个Python程序的6次改进 在 http://blog.csdn.net/tinydust 贴出

下面是总结出来的最快的python实现
import datetime

if __name__ == "__main__":
    t1=datetime.datetime.today()
    f = file("email.txt","r")
    f2 = file("email_new.txt","w")
    f2.writelines(set(f))
    f.close()
    f2.close()
    t2=datetime.datetime.today()
    print str(t2-t1)

在我机器上的测试结果:
python 2.5:  0:00:00.172000
这个程序语言特性用到了极致, 近乎完美地解决了问题,佩服!

一位网友的ruby实现
#!/usr/bin/env ruby
t = Time.new

file = 'email.txt'

f1= File.new('email.txt', 'r')
data = f1.readlines
f1.close

f2 = File.new('email_rb.txt', 'w')
f2.write(data.uniq.join)
f2.close
puts Time.new - t

ruby 2.0.0 (Base: Ruby 1.9.0 2006-04-08) [i386-mswin32]
YARVCore 0.4.1 Rev: 545 (2006-09-01) [opts: [inline method cache] ]

这个程序也很酷,结果  0.391

看了之后,马上产生了用lua写一个同样程序的想法!

lines = {}

f1 = io.open ("email.txt","r")
for line in f1:lines() do lines[line] = true end
f1:close()

f2 = io.open ("e_t.txt","w+")
for line in pairs(lines) do f2:write(line, "\n") end
f2:close()
print(os.clock())

Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio: 0.406
测试结果: Python:Ruby:Lua = 172:391:406

是不是LUA就差了呢!才不是呢!

这也是可以理解的, LUA io操作肯定是没有优化的,没有一次将所有的数据读入/写出,我尝试一次读入出数据,然后对读入的数据按照string的方式来处理,然后一次写盘,测试的结果是比上面的程序慢了一倍,问题在于lua对于字符串的操作同样也为优化,花的时间很长,CPU/内存开销都很大,看来又比要对字符处处理做一个扩展库.
另外将上面的程序两个循环合并成一个同时操作读入/写出文件后性能也不理想,因为同时在两个文件上进行IO操作,硬盘磁头会频繁移动,性能反而降低。LUA的优势要嵌入C/C++才能表现出来!

不过python的表现让我惊奇, rite的表现也很惹人注意。

由于我的开发工作决定使用lua会更好。所以我会继续使用lua.

iolanguage也进入了我的视线,抽空也的研究一下!

星期二, 十月 03, 2006

LuaCOM for Lua 5.1.1 Fixed!

下面的话是我理解错误造成的!
除了上面引用的 LuaCOM - more questions 中所解决的问题外,LuaCOM 在 Lua 5.1.1中还有一个比较严重的问题,那就是 接口 参数传入有问题,具体原因还不太清楚,可能是lua 5.1与lua 5.0在传入函数参数时,对于堆栈的操作发生改变,类似于下面的代码需要修正!


1 多处定义的 self_param=1,并未在其他地方使用,干脆移除,要不干扰我们对代码的理解!
2 文中多处定义的 const int first_param = 2; 会在COM接口lua 5.1中造成第一个参数丢失,所以改成const int first_param = 1
3 const int num_params = luaCompat_getNumParams(L, 4) - 1; 由于first_param 从2改为1,所以把它改成const int num_params = luaCompat_getNumParams(L, 4);

基本上就这样,还需要更多的验证,另外对luacom的改动,需要内lua的VM机制与COM机制有比较深入的认识,说实话,这两件事情都比较复杂,另外由于luacom的不跨平台性,用ATL与luabind来重新实现应该是比较好的选择,代码量可能会更小!

修改,上面的方法存在问题,如果是用obj.method的方法来调用,需要用上面的方法修改,如果用obj:Method的方法来调用的话,就不需要改拉!

LuaCOM - more questions

LuaCOM - more questions

Click to flag this post

by Terry Bayne Jan 31, 2006; 09:26pm :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Good Morning.

I've started using LuaCOM and I have a few questions. I am not a COM guru so please excuse my ignorance.

I am trying to build on the examples from the LuaCOM documentation, and in doing so I have no problem opening up Microsoft Word. The problem comes when I try to create a new document - most of the examples on the web do something like this:

word = luacom.CreateObject("Word.Application")
assert(word)
word.visible = true
-- Works good up to this point
doc = word.Documents.Add()

The last statement fails. I've tried passing parameters, even tried this:

word = luacom.CreateObject("Word.Application")
mt = luacom.CreateObject("type.missing")
assert(word)
word.visible = true
-- Works good up to this point
doc = word.Documents.Add(mt,mt,mt,mt)

All this gets me is a type mismatch error.

Any ideas?

Thanks
Terry


Re: LuaCOM - more questions

Click to flag this post

by Fabio Mascarenhas Jan 31, 2006; 10:08pm :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Hi, Terry,

This:

> doc = word.Documents.Add()

should be this:

doc = word.Documents:Add()

Method calls use ':'. Reading and writing properties use '.'.

--
Fabio Mascarenhas

On 1/31/06, Terry Bayne <tbayne@...> wrote:
> Good Morning.
>
> I've started using LuaCOM and I have a few questions. I am not a COM guru so please excuse my ignorance.
>when I try to create a new document - most of the examples on the web
do >something like this:
>
> word = luacom.CreateObject("Word.Application")
> assert(word)
> word.visible = true
> -- Works good up to this point
> doc = word.Documents.Add()
>
> The last statement fails. I've tried passing parameters, even tried this:
> All this gets me is a type mismatch error.

LuaCOM - more questions

Click to flag this post

by Michael Cumming Jan 31, 2006; 11:01pm :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Terry,

Its

doc = word.Documents:Add()

note the ':' not '.'

Mike

Re: LuaCOM - more questions

Click to flag this post

by Terry Bayne Feb 01, 2006; 12:10am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Fabio,

Thanks for spotting that, but still getting a type mismatch error:

LUA: Calling word.Documents:Add
Error executing lua code: [COM error:(E:\Blackdog\kibble\trunk\luacom\src\library\tLuaCOM.cpp,403):Type mismatch.]

Here is the lua code I am running:

word = luacom.CreateObject("Word.Application")
MT = luacom.CreateObject("type.missing")
assert(word)word.visible = true
print("Calling word.Documents:Add")
doc = word.Documents:Add()
print("Back from Documents:Add()")

Any ideas?

Also I have tried passing MT to the Add() call like so:

doc = word.Documents:Add(MT,MT,MT,MT)

Thanks

On Tue, 31 Jan 2006 12:08:11 -0200, Fabio Mascarenhas wrote:
>> Hi, Terry,
>>
>> This:
>>
>>>> doc = word.Documents.Add()
>>>>
>> should be this:
>>
>> doc = word.Documents:Add()
>>
>> Method calls use ':'. Reading and writing properties use '.'.
>>
>> --
>> Fabio Mascarenhas
>>
>> On 1/31/06, Terry Bayne <tbayne@...> wrote:
>>
>>>> Good Morning.
>>>>
>>>> I've started using LuaCOM and I have a few questions. I am not
>>>> a COM guru so please excuse my ignorance.
>>>> when I try to create a new document - most of the examples on
>>>> the web
>>>>
>> do >something like this:
>>
>>>> word = luacom.CreateObject("Word.Application") assert(word)
>>>> word.visible = true -- Works good up to this point doc =
>>>> word.Documents.Add()
>>>>
>>>> The last statement fails. I've tried passing parameters, even
>>>> tried this: All this gets me is a type mismatch error.


RE: LuaCOM - more questions

Click to flag this post

by Ignacio Burgueño Feb 01, 2006; 01:16am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Hi Terry. What version of LuaCOM are you using? Just tested your sample code
using luaCom 1.2 and Office 2003 and it worked fine.



> -----Original Message-----
> From: lua-bounces@...
> [mailto:lua-bounces@...] On Behalf Of Terry Bayne
> Sent: Tuesday, January 31, 2006 1:15 PM
> To: Lua list
> Subject: Re: LuaCOM - more questions
>
> Fabio,
>
> Thanks for spotting that, but still getting a type mismatch error:
>
> LUA: Calling word.Documents:Add
> Error executing lua code: [COM
> error:(E:\Blackdog\kibble\trunk\luacom\src\library\tLuaCOM.cpp
> ,403):Type mismatch.]
>
> Here is the lua code I am running:
>
> word = luacom.CreateObject("Word.Application")
> MT = luacom.CreateObject("type.missing")
> assert(word)word.visible = true
> print("Calling word.Documents:Add")
> doc = word.Documents:Add()
> print("Back from Documents:Add()")
>
> Any ideas?
>
> Also I have tried passing MT to the Add() call like so:
>
> doc = word.Documents:Add(MT,MT,MT,MT)
>
> Thanks

RE: LuaCOM - more questions

Click to flag this post

by Terry Bayne Feb 01, 2006; 01:41am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Ignacio,

Hi, thank you for taking the time to look at this. I am using LUACom 1.3 with Office 2003 and LUA 5.0.2.

Terry

On Tue, 31 Jan 2006 15:12:24 -0300, Ignacio Burgueño wrote:
>> Hi Terry. What version of LuaCOM are you using? Just tested your
>> sample code using luaCom 1.2 and Office 2003 and it worked fine.
>>
>>
>>>> -----Original Message-----
>>>> From: lua-bounces@...
>>>> [mailto:lua-bounces@...] On Behalf Of Terry
>>>> Bayne Sent: Tuesday, January 31, 2006 1:15 PM To: Lua list
>>>> Subject: Re: LuaCOM - more questions
>>>>
>>>> Fabio,
>>>>
>>>> Thanks for spotting that, but still getting a type mismatch
>>>> error:
>>>>
>>>> LUA: Calling word.Documents:Add
>>>> Error executing lua code: [COM
>>>> error:(E:\Blackdog\kibble\trunk\luacom\src\library\tLuaCOM.cpp
>>>> ,403):Type mismatch.]
>>>>
>>>> Here is the lua code I am running:
>>>>
>>>> word = luacom.CreateObject("Word.Application")
>>>> MT = luacom.CreateObject("type.missing")
>>>> assert(word)word.visible = true
>>>> print("Calling word.Documents:Add")
>>>> doc = word.Documents:Add()
>>>> print("Back from Documents:Add()")
>>>>
>>>> Any ideas?
>>>>
>>>> Also I have tried passing MT to the Add() call like so:
>>>>
>>>> doc = word.Documents:Add(MT,MT,MT,MT)
>>>>
>>>> Thanks


RE: LuaCOM - more questions

Click to flag this post

by Ignacio Burgueño Feb 01, 2006; 05:04am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

Well. I compiled a debug version of luacom 1.3 (as of 2005-02-28) and it
does not work.
Indeed, the code fails when calling the Add method from the Word.Document
class
Its signature is:

HRESULT Add(
[in, optional] VARIANT* Template,
[in, optional] VARIANT* NewTemplate,
[in, optional] VARIANT* DocumentType,
[in, optional] VARIANT* Visible,
[out, retval] Document** prop);

I don't know if luacom 1.3 introduced a new approach to handle optional
parameters, but I think that the problem lies in the function
tLuaCOMTypeHandler::fillDispParams
At line 943, there's this code:

else if(!byref) // here we filter the optional out params (treated
below)
{
// assumes that a parameter is expected but has not been found

var.vt = VT_ERROR;
var.scode = DISP_E_PARAMNOTFOUND;
}

if(!byref || var.vt == VT_ERROR)
{
VariantCopy(&r_rgvarg[i], &var);
VariantClear(&var);
}

byref is true (it was set at line 911), and the parameter is [in] but it
seems that that case isn't handled properly. It should pass a Variant with
VT_ERROR and DISP_E_PARAMNOTFOUND.
I'm not quite sure of how to fix this properly.
Changing line 943 to this works fine:
else if(byref) // here we filter the optional out params (treated
below)
But I didn't check if that breaks other calls.

Regards,

Ignacio Burgueño
Desarrollo - Tecnolink S.A.
ignacio@...

Tel: +598 2 614-1003
www.inConcertCC.com


> -----Original Message-----
> From: lua-bounces@...
> [mailto:lua-bounces@...] On Behalf Of Terry Bayne
> Sent: Tuesday, January 31, 2006 2:45 PM
> To: Lua list
> Subject: RE: LuaCOM - more questions
>
> Ignacio,
>
> Hi, thank you for taking the time to look at this. I am
> using LUACom 1.3 with Office 2003 and LUA 5.0.2.
>
> Terry
>
> On Tue, 31 Jan 2006 15:12:24 -0300, Ignacio Burgueño wrote:
> >> Hi Terry. What version of LuaCOM are you using? Just tested your
> >> sample code using luaCom 1.2 and Office 2003 and it worked fine.
> >>
> >>
> >>>> -----Original Message-----
> >>>> From: lua-bounces@...
> >>>> [mailto:lua-bounces@...] On Behalf Of Terry
> >>>> Bayne Sent: Tuesday, January 31, 2006 1:15 PM To: Lua list
> >>>> Subject: Re: LuaCOM - more questions
> >>>>
> >>>> Fabio,
> >>>>
> >>>> Thanks for spotting that, but still getting a type mismatch
> >>>> error:
> >>>>
> >>>> LUA: Calling word.Documents:Add
> >>>> Error executing lua code: [COM
> >>>> error:(E:\Blackdog\kibble\trunk\luacom\src\library\tLuaCOM.cpp
> >>>> ,403):Type mismatch.]
> >>>>
> >>>> Here is the lua code I am running:
> >>>>
> >>>> word = luacom.CreateObject("Word.Application")
> >>>> MT = luacom.CreateObject("type.missing")
> >>>> assert(word)word.visible = true
> >>>> print("Calling word.Documents:Add")
> >>>> doc = word.Documents:Add()
> >>>> print("Back from Documents:Add()")
> >>>>
> >>>> Any ideas?
> >>>>
> >>>> Also I have tried passing MT to the Add() call like so:
> >>>>
> >>>> doc = word.Documents:Add(MT,MT,MT,MT)
> >>>>
> >>>> Thanks
>
>
>
>

RE: LuaCOM - more questions

Click to flag this post

by Shaun-7 Feb 01, 2006; 05:23am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message


> I don't know if luacom 1.3 introduced a new approach to handle optional
> parameters, but I think that the problem lies in the function
> tLuaCOMTypeHandler::fillDispParams
> At line 943, there's this code:

I had exactly the same problem and implemented a fix exactly like you
suggested.

I sent an email to the maintainer, Fabio Mascarenhas, at the time, but
don't think I ever heard anything back.

Cheers,
Shaun

RE: LuaCOM - more questions

Click to flag this post

by Terry Bayne Feb 01, 2006; 07:43am :: Rate this Message: Click to rate as Poor PostClick to rate as Below Average PostClick to rate as Average PostClick to rate as Above Average PostClick to rate as Excellent Post Click to clear rating - Use ratings to moderate (?)

Reply | Reply to Author | View Threaded | Link to this Message

That did seem to solve the problem! Thanks to both you and Shaun for your help!

Terry

On Tue, 31 Jan 2006 19:07:52 -0300, Ignacio Burgueño wrote:
>> Well. I compiled a debug version of luacom 1.3 (as of 2005-02-28)
>> and it does not work.
>> Indeed, the code fails when calling the Add method from the
>> Word.Document class Its signature is:
>>
>> HRESULT Add(
>> [in, optional] VARIANT* Template,
>> [in, optional] VARIANT* NewTemplate,
>> [in, optional] VARIANT* DocumentType,
>> [in, optional] VARIANT* Visible,
>> [out, retval] Document** prop);
>>
>> I don't know if luacom 1.3 introduced a new approach to handle
>> optional parameters, but I think that the problem lies in the
>> function tLuaCOMTypeHandler::fillDispParams At line 943, there's
>> this code:
>>
>> else if(!byref) // here we filter the optional out params (treated
>> below) {
>> // assumes that a parameter is expected but has not been found
>>
>> var.vt = VT_ERROR;
>> var.scode = DISP_E_PARAMNOTFOUND;
>> }
>>
>> if(!byref || var.vt == VT_ERROR)
>> {
>> VariantCopy(&r_rgvarg[i], &var);
>> VariantClear(&var);
>> }
>>
>> byref is true (it was set at line 911), and the parameter is [in]
>> but it seems that that case isn't handled properly. It should pass
>> a Variant with VT_ERROR and DISP_E_PARAMNOTFOUND. I'm not quite
>> sure of how to fix this properly. Changing line 943 to this works
>> fine:
>> else if(byref) // here we filter the optional out params (treated
>> below) But I didn't check if that breaks other calls.
>>
>> Regards,
>>
>> Ignacio Burgueño
>> Desarrollo - Tecnolink S.A.
>> ignacio@...
>>
>> Tel: +598 2 614-1003
>> www.inConcertCC.com
>>
>>
>>>> -----Original Message-----
>>>> From: lua-bounces@...
>>>> [mailto:lua-bounces@...] On Behalf Of Terry
>>>> Bayne Sent: Tuesday, January 31, 2006 2:45 PM To: Lua list
>>>> Subject: RE: LuaCOM - more questions
>>>>
>>>> Ignacio,
>>>>
>>>> Hi, thank you for taking the time to look at this. I am using
>>>> LUACom 1.3 with Office 2003 and LUA 5.0.2.
>>>>
>>>> Terry
>>>>
>>>> On Tue, 31 Jan 2006 15:12:24 -0300, Ignacio Burgueño wrote:
>>>>
>>>>>> Hi Terry. What version of LuaCOM are you using? Just tested
>>>>>> your sample code using luaCom 1.2 and Office 2003 and it
>>>>>> worked fine.
>>>>>>
>>>>>>
>>>>>>>> -----Original Message-----
>>>>>>>> From: lua-bounces@...
>>>>>>>> [mailto:lua-bounces@...] On Behalf Of
>>>>>>>> Terry Bayne Sent: Tuesday, January 31, 2006 1:15 PM To:
>>>>>>>> Lua list Subject: Re: LuaCOM - more questions
>>>>>>>>
>>>>>>>> Fabio,
>>>>>>>>
>>>>>>>> Thanks for spotting that, but still getting a type
>>>>>>>> mismatch error:
>>>>>>>>
>>>>>>>> LUA: Calling word.Documents:Add
>>>>>>>> Error executing lua code: [COM
>>>>>>>> error:(E:\Blackdog\kibble\trunk\luacom\src\library\tLuaCOM.cpp ,403):
>>>>>>>> Type mismatch.]
>>>>>>>>
>>>>>>>> Here is the lua code I am running:
>>>>>>>>
>>>>>>>> word = luacom.CreateObject("Word.Application")
>>>>>>>> MT = luacom.CreateObject("type.missing")
>>>>>>>> assert(word)word.visible = true
>>>>>>>> print("Calling word.Documents:Add")
>>>>>>>> doc = word.Documents:Add()
>>>>>>>> print("Back from Documents:Add()")
>>>>>>>>
>>>>>>>> Any ideas?
>>>>>>>>
>>>>>>>> Also I have tried passing MT to the Add() call like so:
>>>>>>>>
>>>>>>>> doc = word.Documents:Add(MT,MT,MT,MT)
>>>>>>>>
>>>>>>>> Thanks