- naRef name, namespace = naNewHash(c);
- int i, n = sizeof(funcs)/sizeof(struct func);
- for(i=0; i<n; i++) {
- naRef code = naNewCCode(c, funcs[i].func);
- naRef name = naStr_fromdata(naNewString(c),
- funcs[i].name, strlen(funcs[i].name));
- naHash_set(namespace, name, naNewFunc(c, code));
- }
-
- // Set up constants for math.pi and math.e
- name = naStr_fromdata(naNewString(c), "pi", 2);
- naHash_set(namespace, name, naNum(M_PI));
-
- name = naStr_fromdata(naNewString(c), "e", 1);
- name = naInternSymbol(name);
- naHash_set(namespace, name, naNum(M_E));
-
- return namespace;
+ naRef ns = naGenLib(c, funcs);
+ naAddSym(c, ns, "pi", naNum(3.14159265358979323846));
+ naAddSym(c, ns, "e", naNum(2.7182818284590452354));
+ return ns;