求JScript 内置对象Enumerator的C语言实现解决方案或代码

entaoyang 2008-12-18 10:57:42
我现在需要在SpiderMonkey (JavaScript 的C语言实现版本)中实现Enumerator对象(Enumerator是JScript内置对象),
简单的说, 就是用C++(可以使用win SDK/ActiveX, 不能使用MFC, 也不能使用.net库) 来实现一个Enumerator, 哪位高手有办法??

下面是JScript中Enumerator的用法.

function ShowDriveList(){
var fso, s, n, e, x; //Declare variables.
fso = new ActiveXObject("Scripting.FileSystemObject");
e = new Enumerator(fso.Drives); //Create Enumerator on Drives.
s = "";
for (;!e.atEnd();e.moveNext()) //Enumerate drives collection.
{
x = e.item();
s = s + x.DriveLetter;
s += " - ";
if (x.DriveType == 3) //See if network drive.
n = x.ShareName; //Get share name
else if (x.IsReady) //See if drive is ready.
n = x.VolumeName; //Get volume name.
else
n = "[Drive not ready]";
s += n + "<br>";
}
return(s); //Return active drive list.
}
...全文
39 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yellowhwb 2008-12-18
  • 打赏
  • 举报
回复
Enumerator就是在class里实现某些容器类的遍历算法,如果容器是链表,那就用个for循环来实现遍历,再提供moveNext的方法,就是链表的Next指针,等等,类推!

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧