mirror of
				https://github.com/bellard/quickjs.git
				synced 2025-05-29 01:49:18 +08:00 
			
		
		
		
	added JS_AtomToCStringLen()
This commit is contained in:
		
							parent
							
								
									2f167bbeeb
								
							
						
					
					
						commit
						838124580b
					
				@ -3205,15 +3205,18 @@ static BOOL JS_AtomSymbolHasDescription(JSContext *ctx, JSAtom v)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* free with JS_FreeCString() */
 | 
					/* free with JS_FreeCString() */
 | 
				
			||||||
const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
 | 
					const char *JS_AtomToCStringLen(JSContext *ctx, size_t *plen, JSAtom atom)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    JSValue str;
 | 
					    JSValue str;
 | 
				
			||||||
    const char *cstr;
 | 
					    const char *cstr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    str = JS_AtomToString(ctx, atom);
 | 
					    str = JS_AtomToString(ctx, atom);
 | 
				
			||||||
    if (JS_IsException(str))
 | 
					    if (JS_IsException(str)) {
 | 
				
			||||||
 | 
					        if (plen)
 | 
				
			||||||
 | 
					            *plen = 0;
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    cstr = JS_ToCString(ctx, str);
 | 
					    }
 | 
				
			||||||
 | 
					    cstr = JS_ToCStringLen(ctx, plen, str);
 | 
				
			||||||
    JS_FreeValue(ctx, str);
 | 
					    JS_FreeValue(ctx, str);
 | 
				
			||||||
    return cstr;
 | 
					    return cstr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -456,7 +456,11 @@ void JS_FreeAtom(JSContext *ctx, JSAtom v);
 | 
				
			|||||||
void JS_FreeAtomRT(JSRuntime *rt, JSAtom v);
 | 
					void JS_FreeAtomRT(JSRuntime *rt, JSAtom v);
 | 
				
			||||||
JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom);
 | 
					JSValue JS_AtomToValue(JSContext *ctx, JSAtom atom);
 | 
				
			||||||
JSValue JS_AtomToString(JSContext *ctx, JSAtom atom);
 | 
					JSValue JS_AtomToString(JSContext *ctx, JSAtom atom);
 | 
				
			||||||
const char *JS_AtomToCString(JSContext *ctx, JSAtom atom);
 | 
					const char *JS_AtomToCStringLen(JSContext *ctx, size_t *plen, JSAtom atom);
 | 
				
			||||||
 | 
					static inline const char *JS_AtomToCString(JSContext *ctx, JSAtom atom)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return JS_AtomToCStringLen(ctx, NULL, atom);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val);
 | 
					JSAtom JS_ValueToAtom(JSContext *ctx, JSValueConst val);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* object class support */
 | 
					/* object class support */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user